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>
|