日期:2014-05-16  浏览次数:20916 次

mysql sql中文排序 hibernate HQL中文排序
sql:
select chinese from table1 order by convert(chinese using gb2312) asc;
HQL:
public class MySQL5LocalDialect extends MySQL5InnoDBDialect{ //继承链接mysql的类
public MySQL5LocalDialect() {
super();
registerFunction("convert", new SQLFunctionTemplate(Hibernate.STRING,
"convert(?1 using ?2)"));
}
}

在application.xml中:
<prop key="hibernate.dialect">
com.***.util.MySQL5LocalDialect   <!--导入上面咱自定义的类-->
</prop>