- 书写convert函数让HQL支持convert函数,实现HQL中文排序
代码:
public class MySQL5LocalDialect extends MySQLDialect {
@SuppressWarnings("deprecation")
public MySQL5LocalDialect() {
super();
registerFunction("convert", new SQLFunctionTemplate(Hibernate.STRING, "convert(?1 using ?2)"));
}
}
- hibernate配置
hibernate.dialect com.demo2do.core.utils.MySQL5LocalDialect
- HQL使用
order by convert(account.employee.realName,'gbk') asc