propertyprojection.java

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

JAVA
64
字号
//$Id: PropertyProjection.java 5685 2005-02-12 07:19:50Z steveebersole $package org.hibernate.criterion;import org.hibernate.Criteria;import org.hibernate.HibernateException;import org.hibernate.type.Type;/** * A property value, or grouped property value * @author Gavin King */public class PropertyProjection extends SimpleProjection {	private String propertyName;	private boolean grouped;		protected PropertyProjection(String prop, boolean grouped) {		this.propertyName = prop;		this.grouped = grouped;	}		protected PropertyProjection(String prop) {		this(prop, false);	}	public String getPropertyName() {		return propertyName;	}		public String toString() {		return propertyName;	}	public Type[] getTypes(Criteria criteria, CriteriaQuery criteriaQuery) 	throws HibernateException {		return new Type[] { criteriaQuery.getType(criteria, propertyName) };	}	public String toSqlString(Criteria criteria, int position, CriteriaQuery criteriaQuery) 	throws HibernateException {		return new StringBuffer()			.append( criteriaQuery.getColumn(criteria, propertyName) )			.append(" as y")			.append(position)			.append('_')			.toString();	}	public boolean isGrouped() {		return grouped;	}		public String toGroupSqlString(Criteria criteria, CriteriaQuery criteriaQuery) 	throws HibernateException {		if (!grouped) {			return super.toGroupSqlString(criteria, criteriaQuery);		}		else {			return criteriaQuery.getColumn(criteria, propertyName);		}	}}

⌨️ 快捷键说明

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