HQL查询中文乱码问题 (转)

来源:互联网 发布:有没有在美迪学淘宝的 编辑:程序博客网 时间:2024/06/08 16:19

可以在spring配置文件中配置:

[html] view plaincopyprint?
  1. <property name="hibernateProperties">  
  2.     <props>  
  3.         <prop key="hibernate.dialect">${hibernate.dialect}</prop>  
  4.         <prop key="hibernate.show_sql">${hibernate.show_sql}</prop>  
  5.         <prop key="connection.autocommit">false</prop>  
  6.         <!--   
  7.         <prop key="hibernate.cache.use_second_level_cache">false</prop>  
  8.         <prop key="hibernate.cache.use_query_cache">false</prop>  
  9.          -->  
  10.          <prop key="hibernate.query.factory_class">org.hibernate.hql.classic.ClassicQueryTranslatorFactory</prop>   
  11.     </props>  
  12. </property>  

可以在hibernate.cfg.xml中配置:

[html] view plaincopyprint?
  1. <property name="hibernate.query.factory_class">  
  2.       org.hibernate.hql.classic.ClassicQueryTranslatorFactory  
  3. </property>  

或者在写HQL的时候不吧中文参数拼凑进去,用query的setXxx。
原创粉丝点击