noargsqlfunction.java

来自「一个Java持久层类库」· Java 代码 · 共 50 行

JAVA
50
字号
//$Id: NoArgSQLFunction.java 6608 2005-04-29 15:32:30Z oneovthafew $package org.hibernate.dialect.function;import java.util.List;import org.hibernate.QueryException;import org.hibernate.engine.Mapping;import org.hibernate.engine.SessionFactoryImplementor;import org.hibernate.type.Type;/** * A function which takes no arguments * @author Michi */public class NoArgSQLFunction implements SQLFunction {    private Type returnType;    private boolean hasParenthesesIfNoArguments;    private String name;    public NoArgSQLFunction(String name, Type returnType) {        this(name, returnType, true);    }    public NoArgSQLFunction(String name, Type returnType, boolean hasParenthesesIfNoArguments) {        this.returnType = returnType;        this.hasParenthesesIfNoArguments = hasParenthesesIfNoArguments;        this.name = name;    }    public Type getReturnType(Type columnType, Mapping mapping) throws QueryException {        return returnType;    }    public boolean hasArguments() {        return false;    }    public boolean hasParenthesesIfNoArguments() {        return hasParenthesesIfNoArguments;    }        public String render(List args, SessionFactoryImplementor factory) throws QueryException {    	if ( args.size()>0 ) {    		throw new QueryException("function takes no arguments: " + name);    	}    	return hasParenthesesIfNoArguments ? name + "()" : name;    }}

⌨️ 快捷键说明

复制代码Ctrl + C
搜索代码Ctrl + F
全屏模式F11
增大字号Ctrl + =
减小字号Ctrl + -
显示快捷键?