public class MySQL56FulltextSQLFunction implements SQLFunction {
@Override
public boolean hasArguments() {
return true;
}
@Override
public boolean hasParenthesesIfNoArguments() {
return false;
}
@Override
public Type getReturnType(Type firstArgumentType, Mapping mapping) throws QueryException {
return StandardBasicTypes.BOOLEAN;
}
@Override
public String render(Type firstArgumentType, List arguments, SessionFactoryImplementor factory) throws QueryException {
if (arguments == null || arguments.size() < 2){
throw new IllegalStateException("The function at least 2 arguments");
}
StringBuilder result = new StringBuilder("match(").append(arguments.get(0));
int last = arguments.size()-1;
for (int i=1; i<last; i++){
result.append(",").append(arguments.get(i));
}
result.append(") against(").append(arguments.get(last)).append(")");
return result.toString();
}
}
public class MySQL56InnoDBDialect extends MySQL5InnoDBDialect {
public MySQL56InnoDBDialect() {
super();
registerFunction("fts", new MySQL56FulltextSQLFunction());
}
}