org.hibernate.impl
Class CriteriaImpl.Subcriteria

java.lang.Object
  extended by org.hibernate.impl.CriteriaImpl.Subcriteria
All Implemented Interfaces:
Serializable, Criteria, CriteriaSpecification
Enclosing class:
CriteriaImpl

public final class CriteriaImpl.Subcriteria
extends Object
implements Criteria, Serializable

See Also:
Serialized Form

Field Summary
 
Fields inherited from interface org.hibernate.criterion.CriteriaSpecification
ALIAS_TO_ENTITY_MAP, DISTINCT_ROOT_ENTITY, FULL_JOIN, INNER_JOIN, LEFT_JOIN, PROJECTION, ROOT_ALIAS, ROOT_ENTITY
 
Method Summary
 Criteria add(Criterion expression)
          Add a restriction to constrain the results to be retrieved.
 Criteria addOrder(Order order)
          Add an ordering to the result set.
 Criteria createAlias(String associationPath, String alias)
          Join an association, assigning an alias to the joined association.
 Criteria createAlias(String associationPath, String alias, int joinType)
          Join an association using the specified join-type, assigning an alias to the joined association.
 Criteria createAlias(String associationPath, String alias, int joinType, Criterion withClause)
          Join an association using the specified join-type, assigning an alias to the joined association.
 Criteria createCriteria(String associationPath)
          Create a new Criteria, "rooted" at the associated entity.
 Criteria createCriteria(String associationPath, int joinType)
          Create a new Criteria, "rooted" at the associated entity, using the specified join type.
 Criteria createCriteria(String associationPath, String alias)
          Create a new Criteria, "rooted" at the associated entity, assigning the given alias.
 Criteria createCriteria(String associationPath, String alias, int joinType)
          Create a new Criteria, "rooted" at the associated entity, assigning the given alias and using the specified join type.
 Criteria createCriteria(String associationPath, String alias, int joinType, Criterion withClause)
          Create a new Criteria, "rooted" at the associated entity, assigning the given alias and using the specified join type.
 String getAlias()
          Get the alias of the entity encapsulated by this criteria instance.
 int getJoinType()
           
 LockMode getLockMode()
           
 Criteria getParent()
           
 String getPath()
           
 Criterion getWithClause()
           
 boolean isReadOnly()
          Should entities and proxies loaded by this Criteria be put in read-only mode? If the read-only/modifiable setting was not initialized, then the default read-only/modifiable setting for the persistence context is returned instead.
 boolean isReadOnlyInitialized()
          Was the read-only/modifiable mode explicitly initialized?
 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 based on the given scroll mode.
 void setAlias(String alias)
           
 Criteria setCacheable(boolean cacheable)
          Enable caching of this query result, provided query caching is enabled for the underlying session factory.
 Criteria setCacheMode(CacheMode cacheMode)
          Override the cache mode for this particular query.
 Criteria setCacheRegion(String cacheRegion)
          Set the name of the cache region to use for query result caching.
 Criteria setComment(String comment)
          Add a comment to the generated SQL.
 Criteria setFetchMode(String associationPath, FetchMode mode)
          Specify an association fetching strategy for an association or 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 for this particular query.
 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)
          Used to specify that the query results will be a projection (scalar in nature).
 Criteria setReadOnly(boolean readOnly)
          Set the read-only/modifiable mode for entities and proxies loaded by this Criteria.
 Criteria setResultTransformer(ResultTransformer resultProcessor)
          Set a strategy for handling the query results.
 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
 

Method Detail

toString

public String toString()
Overrides:
toString in class Object

getAlias

public String getAlias()
Description copied from interface: Criteria
Get the alias of the entity encapsulated by this criteria instance.

Specified by:
getAlias in interface Criteria
Returns:
The alias for the encapsulated entity.

setAlias

public void setAlias(String alias)

getPath

public String getPath()

getParent

public Criteria getParent()

getLockMode

public LockMode getLockMode()

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 to be applied
Returns:
this (for method chaining)

getJoinType

public int getJoinType()

getWithClause

public Criterion getWithClause()

add

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

Specified by:
add in interface Criteria
Parameters:
expression - The criterion object representing the restriction to be applied.
Returns:
this (for method chaining)

addOrder

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

Specified by:
addOrder in interface Criteria
Parameters:
order - The order object representing an ordering to be applied to the results.
Returns:
this (for method chaining)

createAlias

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

Functionally equivalent to Criteria.createAlias(String, String, int) using CriteriaSpecification.INNER_JOIN for the joinType.

Specified by:
createAlias in interface Criteria
Parameters:
associationPath - A dot-seperated property path
alias - The alias to assign to the joined association (for later reference).
Returns:
this (for method chaining)

createAlias

public Criteria createAlias(String associationPath,
                            String alias,
                            int joinType)
                     throws HibernateException
Description copied from interface: Criteria
Join an association using the specified join-type, assigning an alias to the joined association.

The joinType is expected to be one of CriteriaSpecification.INNER_JOIN (the default), CriteriaSpecification.FULL_JOIN, or CriteriaSpecification.LEFT_JOIN.

Specified by:
createAlias in interface Criteria
Parameters:
associationPath - A dot-seperated property path
alias - The alias to assign to the joined association (for later reference).
joinType - The type of join to use.
Returns:
this (for method chaining)
Throws:
HibernateException - Indicates a problem creating the sub criteria

createAlias

public Criteria createAlias(String associationPath,
                            String alias,
                            int joinType,
                            Criterion withClause)
                     throws HibernateException
Description copied from interface: Criteria
Join an association using the specified join-type, assigning an alias to the joined association.

The joinType is expected to be one of CriteriaSpecification.INNER_JOIN (the default), CriteriaSpecification.FULL_JOIN, or CriteriaSpecification.LEFT_JOIN.

Specified by:
createAlias in interface Criteria
Parameters:
associationPath - A dot-seperated property path
alias - The alias to assign to the joined association (for later reference).
joinType - The type of join to use.
withClause - The criteria to be added to the join condition (ON clause)
Returns:
this (for method chaining)
Throws:
HibernateException - Indicates a problem creating the sub criteria

createCriteria

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

Functionally equivalent to Criteria.createCriteria(String, int) using CriteriaSpecification.INNER_JOIN for the joinType.

Specified by:
createCriteria in interface Criteria
Parameters:
associationPath - A dot-seperated property path
Returns:
the created "sub criteria"

createCriteria

public Criteria createCriteria(String associationPath,
                               int joinType)
                        throws HibernateException
Description copied from interface: Criteria
Create a new Criteria, "rooted" at the associated entity, using the specified join type.

Specified by:
createCriteria in interface Criteria
Parameters:
associationPath - A dot-seperated property path
joinType - The type of join to use.
Returns:
the created "sub criteria"
Throws:
HibernateException - Indicates a problem creating the sub criteria

createCriteria

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

Functionally equivalent to Criteria.createCriteria(String, String, int) using CriteriaSpecification.INNER_JOIN for the joinType.

Specified by:
createCriteria in interface Criteria
Parameters:
associationPath - A dot-seperated property path
alias - The alias to assign to the joined association (for later reference).
Returns:
the created "sub criteria"

createCriteria

public Criteria createCriteria(String associationPath,
                               String alias,
                               int joinType)
                        throws HibernateException
Description copied from interface: Criteria
Create a new Criteria, "rooted" at the associated entity, assigning the given alias and using the specified join type.

Specified by:
createCriteria in interface Criteria
Parameters:
associationPath - A dot-seperated property path
alias - The alias to assign to the joined association (for later reference).
joinType - The type of join to use.
Returns:
the created "sub criteria"
Throws:
HibernateException - Indicates a problem creating the sub criteria

createCriteria

public Criteria createCriteria(String associationPath,
                               String alias,
                               int joinType,
                               Criterion withClause)
                        throws HibernateException
Description copied from interface: Criteria
Create a new Criteria, "rooted" at the associated entity, assigning the given alias and using the specified join type.

Specified by:
createCriteria in interface Criteria
Parameters:
associationPath - A dot-seperated property path
alias - The alias to assign to the joined association (for later reference).
joinType - The type of join to use.
withClause - The criteria to be added to the join condition (ON clause)
Returns:
the created "sub criteria"
Throws:
HibernateException - Indicates a problem creating the sub criteria

isReadOnly

public boolean isReadOnly()
Description copied from interface: Criteria
Should entities and proxies loaded by this Criteria be put in read-only mode? If the read-only/modifiable setting was not initialized, then the default read-only/modifiable setting for the persistence context is returned instead.

Specified by:
isReadOnly in interface Criteria
Returns:
true, entities and proxies loaded by the criteria will be put in read-only mode false, entities and proxies loaded by the criteria will be put in modifiable mode
See Also:
Criteria.setReadOnly(boolean), The read-only/modifiable setting has no impact on entities/proxies returned by the Criteria that existed in the session before the Criteria was executed., Criteria.isReadOnlyInitialized()

isReadOnlyInitialized

public boolean isReadOnlyInitialized()
Description copied from interface: Criteria
Was the read-only/modifiable mode explicitly initialized?

Specified by:
isReadOnlyInitialized in interface Criteria
Returns:
true, the read-only/modifiable mode was explicitly initialized; false, otherwise.
See Also:
Criteria.setReadOnly(boolean)

setReadOnly

public Criteria setReadOnly(boolean readOnly)
Description copied from interface: Criteria
Set the read-only/modifiable mode for entities and proxies loaded by this Criteria. This setting overrides the default setting for the persistence context.

Specified by:
setReadOnly in interface Criteria
Parameters:
readOnly - true, entities and proxies loaded by the criteria will be put in read-only mode false, entities and proxies loaded by the criteria will be put in modifiable mode
See Also:
To set the default read-only/modifiable setting used for entities and proxies that are loaded into the session:, PersistenceContext.setDefaultReadOnly(boolean), Read-only entities are not dirty-checked and snapshots of persistent state are not maintained. Read-only entities can be modified, but changes are not persisted. When a proxy is initialized, the loaded entity will have the same read-only/modifiable setting as the uninitialized proxy has, regardless of the session's current setting. The read-only/modifiable setting has no impact on entities/proxies returned by the criteria that existed in the session before the criteria was executed.

setCacheable

public Criteria setCacheable(boolean cacheable)
Description copied from interface: Criteria
Enable caching of this query result, provided query caching is enabled for the underlying session factory.

Specified by:
setCacheable in interface Criteria
Parameters:
cacheable - Should the result be considered cacheable; default is to not cache (false).
Returns:
this (for method chaining)

setCacheRegion

public Criteria setCacheRegion(String cacheRegion)
Description copied from interface: Criteria
Set the name of the cache region to use for query result caching.

Specified by:
setCacheRegion in interface Criteria
Parameters:
cacheRegion - the name of a query cache region, or null for the default query cache
Returns:
this (for method chaining)
See Also:
Criteria.setCacheable(boolean)

list

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

Specified by:
list in interface Criteria
Returns:
The list of matched query results.
Throws:
HibernateException - Indicates a problem either translating the criteria to SQL, exeucting the SQL or processing the SQL results.

scroll

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

Specified by:
scroll in interface Criteria
Returns:
The ScrollableResults representing the matched query results.
Throws:
HibernateException - Indicates a problem either translating the criteria to SQL, exeucting the SQL or processing the SQL results.

scroll

public ScrollableResults scroll(ScrollMode scrollMode)
                         throws HibernateException
Description copied from interface: Criteria
Get the results as an instance of ScrollableResults based on the given scroll mode.

Specified by:
scroll in interface Criteria
Parameters:
scrollMode - Indicates the type of underlying database cursor to request.
Returns:
The ScrollableResults representing the matched query results.
Throws:
HibernateException - Indicates a problem either translating the criteria to SQL, exeucting the SQL or processing the SQL results.

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

setFetchMode

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

Specified by:
setFetchMode in interface Criteria
Parameters:
associationPath - a dot seperated property path
mode - The fetch mode for the referenced association
Returns:
this (for method chaining)

setFlushMode

public Criteria setFlushMode(FlushMode flushMode)
Description copied from interface: Criteria
Override the flush mode for this particular query.

Specified by:
setFlushMode in interface Criteria
Parameters:
flushMode - The flush mode to use.
Returns:
this (for method chaining)

setCacheMode

public Criteria setCacheMode(CacheMode cacheMode)
Description copied from interface: Criteria
Override the cache mode for this particular query.

Specified by:
setCacheMode in interface Criteria
Parameters:
cacheMode - The cache mode to use.
Returns:
this (for method chaining)

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 to retrieve, numbered from 0
Returns:
this (for method chaining)

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:
this (for method chaining)

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 - The timeout value to apply.
Returns:
this (for method chaining)
See Also:
Statement.setQueryTimeout(int)

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
Returns:
this (for method chaining)
See Also:
Statement.setFetchSize(int)

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 - The previously assigned alias representing the entity to which the given lock mode should apply.
lockMode - The lock mode to be applied
Returns:
this (for method chaining)

setResultTransformer

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

Specified by:
setResultTransformer in interface Criteria
Parameters:
resultProcessor - The transformer to apply
Returns:
this (for method chaining)
See Also:
CriteriaSpecification.ROOT_ENTITY, CriteriaSpecification.DISTINCT_ROOT_ENTITY, CriteriaSpecification.ALIAS_TO_ENTITY_MAP, CriteriaSpecification.PROJECTION

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
Returns:
this (for method chaining)

setProjection

public Criteria setProjection(Projection projection)
Description copied from interface: Criteria
Used to specify that the query results will be a projection (scalar in nature). Implicitly specifies the CriteriaSpecification.PROJECTION result transformer.

The individual components contained within the given projection determines the overall "shape" of the query result.

Specified by:
setProjection in interface Criteria
Parameters:
projection - The projection representing the overall "shape" of the query results.
Returns:
this (for method chaining)


Copyright © 2001-2010 Red Hat, Inc. All Rights Reserved.