package com.qxueyou.scc.base.handler;
|
|
import java.util.List;
|
|
import org.hibernate.QueryException;
|
import org.hibernate.dialect.function.SQLFunction;
|
import org.hibernate.engine.spi.Mapping;
|
import org.hibernate.engine.spi.SessionFactoryImplementor;
|
import org.hibernate.type.Type;
|
|
public class MatchAgainstFunction implements SQLFunction {
|
|
@Override
|
public Type getReturnType(Type paramType, Mapping paramMapping) throws QueryException {
|
return null;
|
}
|
|
@Override
|
public boolean hasArguments() {
|
return true;
|
}
|
|
@Override
|
public boolean hasParenthesesIfNoArguments() {
|
return false;
|
}
|
|
@SuppressWarnings("rawtypes")
|
@Override
|
public String render(Type paramType, List args, SessionFactoryImplementor paramSessionFactoryImplementor)
|
throws QueryException {
|
StringBuffer buf = new StringBuffer();
|
|
buf.append("MATCH(");
|
|
for (int i = 0; i < args.size() - 1; i++) {
|
buf.append(args.get(i));
|
if (i < args.size() - 2)
|
buf.append(",");
|
}
|
buf.append(")");
|
|
buf.append(" AGAINST(");
|
buf.append(args.get(args.size() - 1));
|
buf.append(" in boolean mode) ");
|
|
return buf.toString();
|
}
|
|
}
|