package com.mandi.common; import java.util.List; import org.hibernate.QueryException; import org.hibernate.dialect.MySQLDialect; import org.hibernate.dialect.function.SQLFunction; import org.hibernate.dialect.function.StandardSQLFunction; import org.hibernate.engine.spi.Mapping; import org.hibernate.engine.spi.SessionFactoryImplementor; import org.hibernate.type.StandardBasicTypes; import org.hibernate.type.Type; public class Custommysqldialect extends MySQLDialect{ protected void registerVarcharTypes(){ registerFunction("group_concat", new StandardSQLFunction("group_concat")); registerFunction("bitand", new SQLFunction() { @Override public String render(Type arg0, List arg1, SessionFactoryImplementor arg2) throws QueryException { if(arg1.size()>1) { return arg1.get(0).toString()+"&"+arg1.get(1).toString(); } return ""; } @Override public boolean hasParenthesesIfNoArguments() { return true; } @Override public boolean hasArguments() { return true; } @Override public Type getReturnType(Type arg0, Mapping arg1) throws QueryException { return StandardBasicTypes.INTEGER; } }); } }