1 首先要确定数据库编码方式为utf-8
可以用命令 show variables like'%char%';
2 查看数据表的和数据字段的默认编码
show create table 数据库名字
3 hibernate.cfg.xml配置文件中改为
<property name="hibernate.connection.url">
<![CDATA[jdbc:mysql://localhost:3306/daycode?useUnicode=true&characterEncoding=utf8]]>
</property>
<![CDATA[jdbc:mysql://localhost:3306/daycode?useUnicode=true&characterEncoding=utf8]]>
</property>
参考文档 http://blog.csdn.net/peditable/article/details/7047573