FileDocCategorySizeDatePackage
SizeExpression.javaAPI DocHibernate 3.2.51944Thu Aug 11 02:26:26 BST 2005org.hibernate.criterion

SizeExpression

public class SizeExpression extends Object implements Criterion
author
Gavin King

Fields Summary
private final String
propertyName
private final int
size
private final String
op
Constructors Summary
protected SizeExpression(String propertyName, int size, String op)

		this.propertyName = propertyName;
		this.size = size;
		this.op = op;
	
Methods Summary
public org.hibernate.engine.TypedValue[]getTypedValues(org.hibernate.Criteria criteria, CriteriaQuery criteriaQuery)

		return new TypedValue[] { 
			new TypedValue( Hibernate.INTEGER, new Integer(size), EntityMode.POJO ) 
		};
	
public java.lang.StringtoSqlString(org.hibernate.Criteria criteria, CriteriaQuery criteriaQuery)

		String role = criteriaQuery.getEntityName(criteria, propertyName) + 
				'." +  
				criteriaQuery.getPropertyName(propertyName);
		QueryableCollection cp = (QueryableCollection) criteriaQuery.getFactory()
				.getCollectionPersister(role);
		//String[] fk = StringHelper.qualify( "collection_", cp.getKeyColumnNames() );
		String[] fk = cp.getKeyColumnNames();
		String[] pk = ( (Loadable) cp.getOwnerEntityPersister() ).getIdentifierColumnNames(); //TODO: handle property-ref
		return "? " + 
				op + 
				" (select count(*) from " +
				cp.getTableName() +
				//" collection_ where " +
				" where " +
				new ConditionFragment()
						.setTableAlias( criteriaQuery.getSQLAlias(criteria, propertyName) )
						.setCondition(pk, fk)
						.toFragmentString() +
				")";
	
public java.lang.StringtoString()

		return propertyName + ".size" + op + size;