⭐ 欢迎来到虫虫下载站! | 📦 资源下载 📁 资源专辑 ℹ️ 关于我们
⭐ 虫虫下载站

📄 standardsqlfunction.java

📁 hibernate-3.1.3-all-src.zip 面向对象的访问数据库工具
💻 JAVA
字号:
//$Id: StandardSQLFunction.java 6528 2005-04-26 18:13:49Z oneovthafew $
package org.hibernate.dialect.function;

import java.util.List;

import org.hibernate.engine.Mapping;
import org.hibernate.engine.SessionFactoryImplementor;
import org.hibernate.type.Type;

/**
 * Provides a standard implementation that supports the majority of the HQL
 * functions that are translated to SQL. The Dialect and its sub-classes use
 * this class to provide details required for processing of the associated
 * function.
 *
 * @author David Channon
 */
public class StandardSQLFunction implements SQLFunction {
	private Type returnType = null;
	private String name;
	
	public StandardSQLFunction(String name) {
		this.name = name;
	}
	
	public StandardSQLFunction(String name, Type typeValue) {
		returnType = typeValue;
		this.name = name;
	}
	
	public Type getReturnType(Type columnType, Mapping mapping) {
		return returnType == null ? columnType : returnType;
	}
	
	public boolean hasArguments() {
		return true;
	}
	
	public boolean hasParenthesesIfNoArguments() {
		return true;
	}
	
	public String render(List args, SessionFactoryImplementor factory) {
		StringBuffer buf = new StringBuffer();
		buf.append(name)
			.append('(');
		for ( int i=0; i<args.size(); i++ ) {
			buf.append( args.get(i) );
			if ( i<args.size()-1 ) buf.append(", ");
		}
		return buf.append(')').toString();
	}
	
	public String toString() {
		return name;
	}
}

⌨️ 快捷键说明

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