org.hibernate.impl
Class CriteriaImpl

java.lang.Object
  extended byorg.hibernate.impl.CriteriaImpl
All Implemented Interfaces:
Criteria, CriteriaSpecification, Serializable

public class CriteriaImpl
extends Object
implements Criteria, Serializable

Implementation of the Criteria interface

Author:
Gavin King
See Also:
Serialized Form

Nested Class Summary
static class CriteriaImpl.CriterionEntry
           
static class CriteriaImpl.OrderEntry
           
 class CriteriaImpl.Subcriteria
           
 
Field Summary
 
Fields inherited from interface org.hibernate.criterion.CriteriaSpecification
ALIAS_TO_ENTITY_MAP, DISTINCT_ROOT_ENTITY, PROJECTION, ROOT_ALIAS, ROOT_ENTITY
 
Constructor Summary
CriteriaImpl(String entityOrClassName, SessionImpl session)
           
CriteriaImpl(String entityOrClassName, String alias, SessionImpl session)
           
 
Method Summary
 Criteria add(Criteria criteriaInst, Criterion expression)
           
 Criteria add(Criterion expression)
          Add a Criterion to constrain the results to be retrieved.
 Criteria addOrder(Order ordering)
          Add an Order to the result set.
protected  void after()
           
protected  void before()
           
 Criteria createAlias(String associationPath, String alias)
          Join an association, assigning an alias to the joined entity
 Criteria createCriteria(String associationPath)
          Create a new Criteria, "rooted" at the associated entity
 Criteria createCriteria(String associationPath, String alias)
          Create a new Criteria, "rooted" at the associated entity, assigning the given alias
 String getAlias()
          Get the alias of the entity
 boolean getCacheable()
           
 String getCacheRegion()
           
 String getComment()
           
 String getEntityOrClassName()
           
 FetchMode getFetchMode(String path)
           
 Integer getFetchSize()
           
 Integer getFirstResult()
           
 Map getLockModes()
           
 Integer getMaxResults()
           
 Projection getProjection()
           
 Criteria getProjectionCriteria()
           
 ResultTransformer getResultTransformer()
           
 SessionImpl getSession()
           
 Integer getTimeout()
           
 boolean isLookupByNaturalKey()
           
 Iterator iterateExpressionEntries()
           
 Iterator iterateOrderings()
           
 Iterator iterateSubcriteria()
           
 List list()
          Get the results.
 ScrollableResults scroll()
          Get the results as an instance of ScrollableResults.
 ScrollableResults scroll(ScrollMode scrollMode)
          Get the results as an instance of ScrollableResults.
 Criteria setCacheable(boolean cacheable)
          Enable caching of this query result set
 Criteria setCacheMode(CacheMode cacheMode)
          Override the cache mode
 Criteria setCacheRegion(String cacheRegion)
          Set the name of the cache region.
 Criteria setComment(String comment)
          Add a comment to the generated SQL
 Criteria setFetchMode(String associationPath, FetchMode mode)
          Specify an association fetching strategy for a one-to-many, many-to-one or one-to-one association, or for a collection of values.
 Criteria setFetchSize(int fetchSize)
          Set a fetch size for the underlying JDBC query.
 Criteria setFirstResult(int firstResult)
          Set the first result to be retrieved.
 Criteria setFlushMode(FlushMode flushMode)
          Override the flush mode
 Criteria setLockMode(LockMode lockMode)
          Set the lock mode of the current entity
 Criteria setLockMode(String alias, LockMode lockMode)
          Set the lock mode of the aliased entity
 Criteria setMaxResults(int maxResults)
          Set a limit upon the number of objects to be retrieved.
 Criteria setProjection(Projection projection)
          Set a projection of projection list, and select the PROJECTION result transformer
 Criteria setResultTransformer(ResultTransformer tupleMapper)
          Set a strategy for handling the query results.
 void setSession(SessionImpl session)
           
 Criteria setTimeout(int timeout)
          Set a timeout for the underlying JDBC query.
 String toString()
           
 Object uniqueResult()
          Convenience method to return a single instance that matches the query, or null if the query returns no results.
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, wait, wait, wait
 

Constructor Detail

CriteriaImpl

public CriteriaImpl(String entityOrClassName,
                    SessionImpl session)

CriteriaImpl

public CriteriaImpl(String entityOrClassName,
                    String alias,
                    SessionImpl session)
Method Detail

setSession

public void setSession(SessionImpl session)

getSession

public SessionImpl getSession()

iterateSubcriteria

public Iterator iterateSubcriteria()

setFlushMode

public Criteria setFlushMode(FlushMode flushMode)
Description copied from interface: Criteria
Override the flush mode

Specified by:
setFlushMode in interface Criteria

setCacheMode

public Criteria setCacheMode(CacheMode cacheMode)
Description copied from interface: Criteria
Override the cache mode

Specified by:
setCacheMode in interface Criteria

setMaxResults

public Criteria setMaxResults(int maxResults)
Description copied from interface: Criteria
Set a limit upon the number of objects to be retrieved.

Specified by:
setMaxResults in interface Criteria
Parameters:
maxResults - the maximum number of results
Returns:
Criteria

setFirstResult

public Criteria setFirstResult(int firstResult)
Description copied from interface: Criteria
Set the first result to be retrieved.

Specified by:
setFirstResult in interface Criteria
Parameters:
firstResult - the first result, numbered from 0
Returns:
Criteria

getFetchSize

public Integer getFetchSize()

setFetchSize

public Criteria setFetchSize(int fetchSize)
Description copied from interface: Criteria
Set a fetch size for the underlying JDBC query.

Specified by:
setFetchSize in interface Criteria
Parameters:
fetchSize - the fetch size

setTimeout

public Criteria setTimeout(int timeout)
Description copied from interface: Criteria
Set a timeout for the underlying JDBC query.

Specified by:
setTimeout in interface Criteria
Parameters:
timeout -
Returns:
Criteria

add

public Criteria add(Criterion expression)
Description copied from interface: Criteria
Add a Criterion to constrain the results to be retrieved.

Specified by:
add in interface Criteria
Parameters:
expression -
Returns:
Criteria

getAlias

public String getAlias()
Description copied from interface: Criteria
Get the alias of the entity

Specified by:
getAlias in interface Criteria

getMaxResults

public Integer getMaxResults()

getFirstResult

public Integer getFirstResult()

getTimeout

public Integer getTimeout()

list

public List list()
          throws HibernateException
Description copied from interface: Criteria
Get the results.

Specified by:
list in interface Criteria
Returns:
List
Throws:
HibernateException

scroll

public ScrollableResults scroll()
Description copied from interface: Criteria
Get the results as an instance of ScrollableResults.

Specified by:
scroll in interface Criteria
Returns:
ScrollableResults

scroll

public ScrollableResults scroll(ScrollMode scrollMode)
Description copied from interface: Criteria
Get the results as an instance of ScrollableResults.

Specified by:
scroll in interface Criteria
Returns:
ScrollableResults

getCacheable

public boolean getCacheable()

getCacheRegion

public String getCacheRegion()

setCacheable

public Criteria setCacheable(boolean cacheable)
Description copied from interface: Criteria
Enable caching of this query result set

Specified by:
setCacheable in interface Criteria

setCacheRegion

public Criteria setCacheRegion(String cacheRegion)
Description copied from interface: Criteria
Set the name of the cache region.

Specified by:
setCacheRegion in interface Criteria
Parameters:
cacheRegion - the name of a query cache region, or null for the default query cache

iterateExpressionEntries

public Iterator iterateExpressionEntries()

iterateOrderings

public Iterator iterateOrderings()

toString

public String toString()

addOrder

public Criteria addOrder(Order ordering)
Description copied from interface: Criteria
Add an Order to the result set.

Specified by:
addOrder in interface Criteria
Parameters:
ordering -
Returns:
Criteria

getFetchMode

public FetchMode getFetchMode(String path)

setFetchMode

public Criteria setFetchMode(String associationPath,
                             FetchMode mode)
Description copied from interface: Criteria
Specify an association fetching strategy for a one-to-many, many-to-one or one-to-one association, or for a collection of values.

Specified by:
setFetchMode in interface Criteria
Parameters:
associationPath - a dot seperated property path
mode - the fetch mode
Returns:
the Criteria object for method chaining

createAlias

public Criteria createAlias(String associationPath,
                            String alias)
                     throws HibernateException
Description copied from interface: Criteria
Join an association, assigning an alias to the joined entity

Specified by:
createAlias in interface Criteria
Throws:
HibernateException

add

public Criteria add(Criteria criteriaInst,
                    Criterion expression)

uniqueResult

public Object uniqueResult()
                    throws HibernateException
Description copied from interface: Criteria
Convenience method to return a single instance that matches the query, or null if the query returns no results.

Specified by:
uniqueResult in interface Criteria
Returns:
the single result or null
Throws:
HibernateException - if there is more than one matching result

getEntityOrClassName

public String getEntityOrClassName()

createCriteria

public Criteria createCriteria(String associationPath,
                               String alias)
                        throws HibernateException
Description copied from interface: Criteria
Create a new Criteria, "rooted" at the associated entity, assigning the given alias

Specified by:
createCriteria in interface Criteria
Throws:
HibernateException

createCriteria

public Criteria createCriteria(String associationPath)
                        throws HibernateException
Description copied from interface: Criteria
Create a new Criteria, "rooted" at the associated entity

Specified by:
createCriteria in interface Criteria
Throws:
HibernateException

setLockMode

public Criteria setLockMode(LockMode lockMode)
Description copied from interface: Criteria
Set the lock mode of the current entity

Specified by:
setLockMode in interface Criteria
Parameters:
lockMode - the lock mode

setLockMode

public Criteria setLockMode(String alias,
                            LockMode lockMode)
Description copied from interface: Criteria
Set the lock mode of the aliased entity

Specified by:
setLockMode in interface Criteria
Parameters:
alias - an alias
lockMode - the lock mode

getLockModes

public Map getLockModes()

getResultTransformer

public ResultTransformer getResultTransformer()

setResultTransformer

public Criteria setResultTransformer(ResultTransformer tupleMapper)
Description copied from interface: Criteria
Set a strategy for handling the query results. This determines the "shape" of the query result set.

Specified by:
setResultTransformer in interface Criteria
Parameters:
tupleMapper -
See Also:
CriteriaSpecification.ROOT_ENTITY, CriteriaSpecification.DISTINCT_ROOT_ENTITY, CriteriaSpecification.ALIAS_TO_ENTITY_MAP

setComment

public Criteria setComment(String comment)
Description copied from interface: Criteria
Add a comment to the generated SQL

Specified by:
setComment in interface Criteria
Parameters:
comment - a human-readable string

getComment

public String getComment()

setProjection

public Criteria setProjection(Projection projection)
Description copied from interface: Criteria
Set a projection of projection list, and select the PROJECTION result transformer

Specified by:
setProjection in interface Criteria

getProjection

public Projection getProjection()

getProjectionCriteria

public Criteria getProjectionCriteria()

before

protected void before()

after

protected void after()

isLookupByNaturalKey

public boolean isLookupByNaturalKey()