hibernate不能实现的数据库函数怎么使用呢

来源:互联网 发布:美团大数据 编辑:程序博客网 时间:2024/06/11 05:17

重写hibernate方言

package com.ayu.hibernate.test;

import org.hibernate.Hibernate;
import org.hibernate.dialect.MySQLDialect;
import org.hibernate.dialect.function.StandardSQLFunction;

public class AyuMySQLDialect extends MySQLDialect {

protected void registerVarcharTypes() {
   registerFunction("group_concat", new StandardSQLFunction("group_concat",Hibernate.STRING));
}
}

<prop key="hibernate.dialect">com.ayu.hibernate.test.AyuMySQLDialect</prop>

hql语句:select f.fid,group_concat(f.fname) from Fund f group by f.user.uid

原创粉丝点击