FileDocCategorySizeDatePackage
CriteriaImpl.javaAPI DocHibernate 3.2.513877Mon Jan 23 14:21:02 GMT 2006org.hibernate.impl

CriteriaImpl

public class CriteriaImpl extends Object implements Serializable, org.hibernate.Criteria
Implementation of the Criteria interface
author
Gavin King

Fields Summary
private final String
entityOrClassName
private transient org.hibernate.engine.SessionImplementor
session
private final String
rootAlias
private List
criterionEntries
private List
orderEntries
private org.hibernate.criterion.Projection
projection
private org.hibernate.Criteria
projectionCriteria
private List
subcriteriaList
private Map
fetchModes
private Map
lockModes
private Integer
maxResults
private Integer
firstResult
private Integer
timeout
private Integer
fetchSize
private boolean
cacheable
private String
cacheRegion
private String
comment
private org.hibernate.FlushMode
flushMode
private org.hibernate.CacheMode
cacheMode
private org.hibernate.FlushMode
sessionFlushMode
private org.hibernate.CacheMode
sessionCacheMode
private org.hibernate.transform.ResultTransformer
resultTransformer
Constructors Summary
public CriteriaImpl(String entityOrClassName, org.hibernate.engine.SessionImplementor session)



	// Constructors ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~

	     
		this(entityOrClassName, ROOT_ALIAS, session);
	
public CriteriaImpl(String entityOrClassName, String alias, org.hibernate.engine.SessionImplementor session)

		this.session = session;
		this.entityOrClassName = entityOrClassName;
		this.cacheable = false;
		this.rootAlias = alias;
	
Methods Summary
public org.hibernate.Criteriaadd(org.hibernate.Criteria criteriaInst, org.hibernate.criterion.Criterion expression)

		criterionEntries.add( new CriterionEntry(expression, criteriaInst) );
		return this;
	
public org.hibernate.Criteriaadd(org.hibernate.criterion.Criterion expression)

		add( this, expression );
		return this;
	
public org.hibernate.CriteriaaddOrder(org.hibernate.criterion.Order ordering)

		orderEntries.add( new OrderEntry( ordering, this ) );
		return this;
	
protected voidafter()

		if ( sessionFlushMode != null ) {
			getSession().setFlushMode( sessionFlushMode );
			sessionFlushMode = null;
		}
		if ( sessionCacheMode != null ) {
			getSession().setCacheMode( sessionCacheMode );
			sessionCacheMode = null;
		}
	
protected voidbefore()

		if ( flushMode != null ) {
			sessionFlushMode = getSession().getFlushMode();
			getSession().setFlushMode( flushMode );
		}
		if ( cacheMode != null ) {
			sessionCacheMode = getSession().getCacheMode();
			getSession().setCacheMode( cacheMode );
		}
	
public org.hibernate.CriteriacreateAlias(java.lang.String associationPath, java.lang.String alias)

		return createAlias( associationPath, alias, INNER_JOIN );
	
public org.hibernate.CriteriacreateAlias(java.lang.String associationPath, java.lang.String alias, int joinType)

		new Subcriteria( this, associationPath, alias, joinType );
		return this;
	
public org.hibernate.CriteriacreateCriteria(java.lang.String associationPath)

		return createCriteria( associationPath, INNER_JOIN );
	
public org.hibernate.CriteriacreateCriteria(java.lang.String associationPath, int joinType)

		return new Subcriteria( this, associationPath, joinType );
	
public org.hibernate.CriteriacreateCriteria(java.lang.String associationPath, java.lang.String alias)

		return createCriteria( associationPath, alias, INNER_JOIN );
	
public org.hibernate.CriteriacreateCriteria(java.lang.String associationPath, java.lang.String alias, int joinType)

		return new Subcriteria( this, associationPath, alias, joinType );
	
public java.lang.StringgetAlias()

		return rootAlias;
	
public java.lang.StringgetCacheRegion()

		return this.cacheRegion;
	
public booleangetCacheable()

		return this.cacheable;
	
public java.lang.StringgetComment()

		return comment;
	
public java.lang.StringgetEntityOrClassName()

		return entityOrClassName;
	
public org.hibernate.FetchModegetFetchMode(java.lang.String path)

		return (FetchMode) fetchModes.get(path);
	
public java.lang.IntegergetFetchSize()

		return fetchSize;
	
public java.lang.IntegergetFirstResult()

		return firstResult;
	
public java.util.MapgetLockModes()

		return lockModes;
	
public java.lang.IntegergetMaxResults()

		return maxResults;
	
public org.hibernate.criterion.ProjectiongetProjection()

		return projection;
	
public org.hibernate.CriteriagetProjectionCriteria()

		return projectionCriteria;
	
public org.hibernate.transform.ResultTransformergetResultTransformer()

		return resultTransformer;
	
public org.hibernate.engine.SessionImplementorgetSession()

		return session;
	
public java.lang.IntegergetTimeout()

		return timeout;
	
public booleanisLookupByNaturalKey()

		if ( projection != null ) {
			return false;
		}
		if ( subcriteriaList.size() > 0 ) {
			return false;
		}
		if ( criterionEntries.size() != 1 ) {
			return false;
		}
		CriterionEntry ce = (CriterionEntry) criterionEntries.get(0);
		return ce.getCriterion() instanceof NaturalIdentifier;
	
public java.util.IteratoriterateExpressionEntries()

		return criterionEntries.iterator();
	
public java.util.IteratoriterateOrderings()

		return orderEntries.iterator();
	
public java.util.IteratoriterateSubcriteria()

		return subcriteriaList.iterator();
	
public java.util.Listlist()

		before();
		try {
			return session.list( this );
		}
		finally {
			after();
		}
	
public org.hibernate.ScrollableResultsscroll()

		return scroll( ScrollMode.SCROLL_INSENSITIVE );
	
public org.hibernate.ScrollableResultsscroll(org.hibernate.ScrollMode scrollMode)

		before();
		try {
			return session.scroll(this, scrollMode);
		}
		finally {
			after();
		}
	
public org.hibernate.CriteriasetCacheMode(org.hibernate.CacheMode cacheMode)

		this.cacheMode = cacheMode;
		return this;
	
public org.hibernate.CriteriasetCacheRegion(java.lang.String cacheRegion)

		this.cacheRegion = cacheRegion.trim();
		return this;
	
public org.hibernate.CriteriasetCacheable(boolean cacheable)

		this.cacheable = cacheable;
		return this;
	
public org.hibernate.CriteriasetComment(java.lang.String comment)

		this.comment = comment;
		return this;
	
public org.hibernate.CriteriasetFetchMode(java.lang.String associationPath, org.hibernate.FetchMode mode)

		fetchModes.put( associationPath, mode );
		return this;
	
public org.hibernate.CriteriasetFetchSize(int fetchSize)

		this.fetchSize = new Integer(fetchSize);
		return this;
	
public org.hibernate.CriteriasetFirstResult(int firstResult)

		this.firstResult = new Integer(firstResult);
		return this;
	
public org.hibernate.CriteriasetFlushMode(org.hibernate.FlushMode flushMode)

		this.flushMode = flushMode;
		return this;
	
public org.hibernate.CriteriasetLockMode(org.hibernate.LockMode lockMode)

		return setLockMode( getAlias(), lockMode );
	
public org.hibernate.CriteriasetLockMode(java.lang.String alias, org.hibernate.LockMode lockMode)

		lockModes.put( alias, lockMode );
		return this;
	
public org.hibernate.CriteriasetMaxResults(int maxResults)

		this.maxResults = new Integer(maxResults);
		return this;
	
public org.hibernate.CriteriasetProjection(org.hibernate.criterion.Projection projection)

		this.projection = projection;
		this.projectionCriteria = this;
		setResultTransformer( PROJECTION );
		return this;
	
public org.hibernate.CriteriasetResultTransformer(org.hibernate.transform.ResultTransformer tupleMapper)

		this.resultTransformer = tupleMapper;
		return this;
	
public voidsetSession(org.hibernate.engine.SessionImplementor session)

		this.session = session;
	
public org.hibernate.CriteriasetTimeout(int timeout)

		this.timeout = new Integer(timeout);
		return this;
	
public java.lang.StringtoString()

		return "CriteriaImpl(" +
			entityOrClassName + ":" +
			(rootAlias==null ? "" : rootAlias) +
			subcriteriaList.toString() +
			criterionEntries.toString() +
			( projection==null ? "" : projection.toString() ) +
			')";
	
public java.lang.ObjectuniqueResult()

		return AbstractQueryImpl.uniqueElement( list() );