原因:Hibernate的基础还是JDBC,所以一样需要设置characterEncoding!
解决方法:
在hibernate.cfg.xml中应该这样写
<property name="connection.url">jdbc:mysql://localhost:3306/yidishui?useUnicode=true&characterEncoding=UTF-8</property>
#hibernate.connection.url jdbc:mysql://localhost:3306/test?useUnicode=true&characterEncoding=UTF-8
ps:处理中文的话,characterEncoding用GBK一样可以。
但字节编码问题最好的解决方法还是统一使用UTF-8!!!