(1)首先新建一个MySQLLocalDialect类对MySQLDialect进行扩展
package utils;
import org.hibernate.Hibernate;
import org.hibernate.dialect.MySQLDialect;
import org.hibernate.dialect.function.SQLFunctionTemplate;
import org.hibernate.type.StringType;
public class MySQLLocalDialectextends MySQLDialect{
public MySQLLocalDialect(){
}
(2)修改applicationContext-hibermate.xml中的配置
<propertyname="hibernateProperties">
</property>
(3)再写查询语句就可以了。
String SQL="from CourseTeacher a where a.worker.workerId=? order by convert_gbk(a.course.name)";