Hibernate映射乱码

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&amp;characterEncoding=utf-8">
</property>

posted @ 2016-07-14 16:59  SaraMorning  阅读(305)  评论(0编辑  收藏  举报