派生自 projectDept/qhighschool

EricsHu
2022-12-05 f1bd8ee1a861eee55ee07eb313cdda51c3f31d98
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
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();
    }
 
}