分享

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

 dddTTLee 2010-11-24

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>

 

    本站是提供个人知识管理的网络存储空间,所有内容均由用户发布,不代表本站观点。请注意甄别内容中的联系方式、诱导购买等信息,谨防诈骗。如发现有害或侵权内容,请点击一键举报。
    转藏 分享 献花(0

    0条评论

    发表

    请遵守用户 评论公约

    类似文章 更多