hql不支持utf-8的汉字按拼音排序,需要转换成gbk,这就要扩展数据库方言,用的是mysql数据库:
package com.jbms.util;
import org.hibernate.dialect.MySQLDialect;
import org.hibernate.dialect.function.SQLFunctionTemplate;
public class MySQLLocalDialect extends MySQLDialect {
public MySQLLocalDialect(){
super();
registerFunction("convert", new SQLFunctionTemplate(org.hibernate.Hibernate.STRING, "convert(?1 using ?2)") );
}
}
同时修改数据库方言配置:
<property name="hibernateProperties">
<props>
<prop key="hibernate.dialect">
<!-- org.hibernate.dialect.MySQLDialect-->
com.jbms.util.MySQLLocalDialect
</prop>
<prop key="hibernate.show_sql">true</prop>
</props>
</property>
参考:http://blog.sina.com.cn/s/blog_624a352c0100qkaq.html
http://www.oschina.net/bbs/thread/302
分享到:
相关推荐
Hibernate hql查询语法总结 Hibernate hql查询语法总结
Hibernate HQL基础练习小列子+数据库
Hibernate HQL.txt Hibernate HQL.txt Hibernate HQL.txt
对hibernate的hql进行了详尽的讲解
Hibernate中的关联查询实际上生成的是数据库表连接查询的SQL语句
hibernate查询之HQLhibernate查询之HQLhibernate查询之HQL
Hibernate HQL 深度历险 深入讲解Hibernate HQL 查询
Hibernate HQL.docHibernate HQL.docHibernate HQL.doc
hibernate hql基本操作
hibernate hql各类查询范例
一个关于Hibernate-HQL 的文档 内容实际而且实用
Hibernate HQL命名参数和Query接口的分页 Hibernate HQL命名参数和Query接口的分页
Hibernate HQL查询 分页查询 模糊查询.docxHibernate HQL查询 分页查询 模糊查询.docxHibernate HQL查询 分页查询 模糊查询.docxHibernate HQL查询 分页查询 模糊查询.docxHibernate HQL查询 分页查询 模糊查询....
hibernate-HQL语句大全
Hibernate查询语言HQL.PPT
Hibernate HQL 插入,查询,更新
Hibernate 多对多HQL语句写法
weblogic12 下最新 org.hibernate.hql.ast.HqlToken解决办法
hibernate hql语句 hql语言汇总
hibernate hql 语言大全 hql学习,这个文档是一个很全面,很不错的