有时候我们使用一些数据库特有的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)") );
}
}
原创文章,作者:Maggie-Hunter,如若转载,请注明出处:https://blog.ytso.com/tech/pnotes/10096.html