posts - 119, comments - 62, trackbacks - 0, articles - 0

Hibernate 3中文问题的解决办法。

Posted on 2006-04-24 15:19 Kevin Meng 阅读(249) 评论(0)  编辑  收藏

在Hibernate 3中,如果HQL语句中有中文,Hibernate生成的SQL语句将会有乱码。例如HQL语句"from Churukou as c where c.name='阿蒙'",在控制台中打出的语句为:Hibernate: select churukou0_.OBJECTID as OBJECTID, churukou0_.NAME as NAME0_ from SDE.CHURUKOU churukou0_ where churukou0_.NAME='???è'
解决办法是在hibernate的设置文件hibernate.cfg.xml的</session-factory>中加入这么一行:
<property name="hibernate.query.factory_class">org.hibernate.hql.classic.ClassicQueryTranslatorFactory</property>


只有注册用户登录后才能发表评论。


网站导航: