创建 MySqlInnoDBDialect 如下
public class MySqlInnoDBDialect extends MySQL5Dialect
{
public boolean supportsCascadeDelete()
{
return true;
}
public String getTableTypeString()
{
return " ENGINE=InnoDB DEFAULT CHARSET=utf8";
}
public boolean hasSelfReferentialForeignKeyBug()
{
return true;
}
}
在hibernate.cfg.xml配置修改
<property name="hibernate.dialect">
org.hibernate.dialect.MySQLDialect
</property>
<property name="hibernate.connection.url">
jdbc:mysql://localhost:3306/test?useUnicode=true&characterEncoding=utf-8
</property>
这样创建的表格编码就是 InnoDB UTF8
已经创建的表格 只能用sql 语句自行修改了