有时候我们使用一些数据库特有的SQL语法跟HQL有冲突怎么办,看看这个
MySQLExtendDialect.java
/**
* MySQLExtendDialect.java of new_dlog_cn
*/
package com.dlog4j.tester;
import org.hibernate.Hibernate;
import org.hibernate.dialect.*;
import org.hibernate.dialect.function.SQLFunctionTemplate;
/**
* MySQL扩展方言
* @author Winter Lau
*/
public class MySQLExtendDialect extends MySQLDialect {
public MySQLExtendDialect(){
super();
registerFunction("convert_gbk",
new SQLFunctionTemplate(Hibernate.STRING, "convert(?1 using gbk)") );
}
}