1、修改数据库字符集:将数据库默认编码设置为UTF-8
CHARSET=utf8
2、配置Hibernate环境时将数据库URL设置成:
jdbc:mysql://localhost:3306/dbName?useUnicode=true&characterEncoding=UTF-8
3、在hibernate.cfg.xml中设置如下属性:
<property name="url"
value="jdbc:mysql://localhost:3306/test?useUnicode=true&characterEncoding=utf-8">
</property>