`
wsqwsq000
  • 浏览: 675519 次
  • 性别: Icon_minigender_1
  • 来自: 深圳
社区版块
存档分类
最新评论

Hql传中文参数出现乱码解决办法

    博客分类:
  • j2ee
 
阅读更多

Hql传中文参数出现乱码(同sql传中文参数出现乱码一样):

解决方法为:
1
、采用占位符,然后setString

2、将 hibernate.query.factory_class 属性设置成

org.hibernate.hql.classic.ClassicQueryTranslatorFactory

 

spring配置文件中加入红色部分
<bean id="sessionFactory"
   class="org.springframework.orm.hibernate3.LocalSessionFactoryBean">
   ........
   <property name="hibernateProperties">
    <props>
     <prop key="hibernate.dialect">
      org.hibernate.dialect.SQLServerDialect
     </prop>
    
<prop key="hibernate.query.factory_class">
             org.hibernate.hql.classic.ClassicQueryTranslatorFactory    
      </prop>
    
    </props>
   </property>
.............
</bean>

 

分享到:
评论

相关推荐

Global site tag (gtag.js) - Google Analytics