By default the MySqlDialect who is coming with Hibernate does MySQL not force to UTF. And by default all binary columns are mapped to “tinyblob”. That’s why I wrote my own Dialect. It is very easy to do. Just a fiew lines of code. Here is my own MySql5Dialect.
import org.hibernate.dialect.MySQL5InnoDBDialect; import java.sql.Types; public class MySql5Dialect extends MySQL5InnoDBDialect { public String getTableTypeString() { return " ENGINE=InnoDB DEFAULT CHARSET=utf8"; } public MySql5Dialect() { super(); registerColumnType( Types.BINARY, "MEDIUMBLOB" ); } }
You can use by adding this to your hibernate.properties files:
hibernate.dialect=org.<your_package_name>.MySql5Dialect