Package org.hibernate.impl
Class CriteriaImpl
java.lang.Object
org.hibernate.impl.CriteriaImpl
- All Implemented Interfaces:
Serializable,Criteria,CriteriaSpecification
Implementation of the Criteria interface
- See Also:
-
Nested Class Summary
Nested ClassesModifier and TypeClassDescriptionstatic final classstatic final classfinal class -
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 -
Constructor Summary
ConstructorsConstructorDescriptionCriteriaImpl(String entityOrClassName, String alias, SessionImplementor session) CriteriaImpl(String entityOrClassName, SessionImplementor session) -
Method Summary
Modifier and TypeMethodDescriptionAdd arestrictionto constrain the results to be retrieved.Add anorderingto the result set.protected voidafter()protected voidbefore()createAlias(String associationPath, String alias) Join an association, assigning an alias to the joined association.createAlias(String associationPath, String alias, int joinType) Join an association using the specified join-type, assigning an alias to the joined association.createAlias(String associationPath, String alias, int joinType, Criterion withClause) Join an association using the specified join-type, assigning an alias to the joined association.createCriteria(String associationPath) Create a new Criteria, "rooted" at the associated entity.createCriteria(String associationPath, int joinType) Create a new Criteria, "rooted" at the associated entity, using the specified join type.createCriteria(String associationPath, String alias) Create a new Criteria, "rooted" at the associated entity, assigning the given alias.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.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.getAlias()Get the alias of the entity encapsulated by this criteria instance.booleangetFetchMode(String path) booleanbooleanShould 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.booleanWas the read-only/modifiable mode explicitly initialized?list()Get the results.scroll()Get the results as an instance ofScrollableResultsscroll(ScrollMode scrollMode) Get the results as an instance ofScrollableResultsbased on the given scroll mode.setCacheable(boolean cacheable) Enable caching of this query result, provided query caching is enabled for the underlying session factory.setCacheMode(CacheMode cacheMode) Override the cache mode for this particular query.setCacheRegion(String cacheRegion) Set the name of the cache region to use for query result caching.setComment(String comment) Add a comment to the generated SQL.setFetchMode(String associationPath, FetchMode mode) Specify an association fetching strategy for an association or a collection of values.setFetchSize(int fetchSize) Set a fetch size for the underlying JDBC query.setFirstResult(int firstResult) Set the first result to be retrieved.setFlushMode(FlushMode flushMode) Override the flush mode for this particular query.setLockMode(String alias, LockMode lockMode) Set the lock mode of the aliased entitysetLockMode(LockMode lockMode) Set the lock mode of the current entitysetMaxResults(int maxResults) Set a limit upon the number of objects to be retrieved.setProjection(Projection projection) Used to specify that the query results will be a projection (scalar in nature).setReadOnly(boolean readOnly) Set the read-only/modifiable mode for entities and proxies loaded by this Criteria.setResultTransformer(ResultTransformer tupleMapper) Set a strategy for handling the query results.voidsetSession(SessionImplementor session) setTimeout(int timeout) Set a timeout for the underlying JDBC query.toString()Convenience method to return a single instance that matches the query, or null if the query returns no results.
-
Constructor Details
-
CriteriaImpl
-
CriteriaImpl
-
-
Method Details
-
toString
-
getSession
-
setSession
-
getEntityOrClassName
-
getLockModes
-
getProjectionCriteria
-
iterateSubcriteria
-
iterateExpressionEntries
-
iterateOrderings
-
add
-
getAlias
Description copied from interface:CriteriaGet the alias of the entity encapsulated by this criteria instance. -
getProjection
-
setProjection
Description copied from interface:CriteriaUsed to specify that the query results will be a projection (scalar in nature). Implicitly specifies theCriteriaSpecification.PROJECTIONresult transformer. The individual components contained within the givenprojectiondetermines the overall "shape" of the query result.- Specified by:
setProjectionin interfaceCriteria- Parameters:
projection- The projection representing the overall "shape" of the query results.- Returns:
- this (for method chaining)
-
add
Description copied from interface:CriteriaAdd arestrictionto constrain the results to be retrieved. -
addOrder
Description copied from interface:CriteriaAdd anorderingto the result set. -
getFetchMode
-
setFetchMode
Description copied from interface:CriteriaSpecify an association fetching strategy for an association or a collection of values.- Specified by:
setFetchModein interfaceCriteria- Parameters:
associationPath- a dot seperated property pathmode- The fetch mode for the referenced association- Returns:
- this (for method chaining)
-
setLockMode
Description copied from interface:CriteriaSet the lock mode of the current entity- Specified by:
setLockModein interfaceCriteria- Parameters:
lockMode- The lock mode to be applied- Returns:
- this (for method chaining)
-
setLockMode
Description copied from interface:CriteriaSet the lock mode of the aliased entity- Specified by:
setLockModein interfaceCriteria- 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)
-
createAlias
Description copied from interface:CriteriaJoin an association, assigning an alias to the joined association. Functionally equivalent toCriteria.createAlias(String, String, int)usingCriteriaSpecification.INNER_JOINfor the joinType.- Specified by:
createAliasin interfaceCriteria- Parameters:
associationPath- A dot-seperated property pathalias- The alias to assign to the joined association (for later reference).- Returns:
- this (for method chaining)
-
createAlias
Description copied from interface:CriteriaJoin an association using the specified join-type, assigning an alias to the joined association. The joinType is expected to be one ofCriteriaSpecification.INNER_JOIN(the default),CriteriaSpecification.FULL_JOIN, orCriteriaSpecification.LEFT_JOIN.- Specified by:
createAliasin interfaceCriteria- Parameters:
associationPath- A dot-seperated property pathalias- The alias to assign to the joined association (for later reference).joinType- The type of join to use.- Returns:
- this (for method chaining)
-
createAlias
public Criteria createAlias(String associationPath, String alias, int joinType, Criterion withClause) Description copied from interface:CriteriaJoin an association using the specified join-type, assigning an alias to the joined association. The joinType is expected to be one ofCriteriaSpecification.INNER_JOIN(the default),CriteriaSpecification.FULL_JOIN, orCriteriaSpecification.LEFT_JOIN.- Specified by:
createAliasin interfaceCriteria- Parameters:
associationPath- A dot-seperated property pathalias- 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)
-
createCriteria
Description copied from interface:CriteriaCreate a new Criteria, "rooted" at the associated entity. Functionally equivalent toCriteria.createCriteria(String, int)usingCriteriaSpecification.INNER_JOINfor the joinType.- Specified by:
createCriteriain interfaceCriteria- Parameters:
associationPath- A dot-seperated property path- Returns:
- the created "sub criteria"
-
createCriteria
Description copied from interface:CriteriaCreate a new Criteria, "rooted" at the associated entity, using the specified join type.- Specified by:
createCriteriain interfaceCriteria- Parameters:
associationPath- A dot-seperated property pathjoinType- The type of join to use.- Returns:
- the created "sub criteria"
-
createCriteria
Description copied from interface:CriteriaCreate a new Criteria, "rooted" at the associated entity, assigning the given alias. Functionally equivalent toCriteria.createCriteria(String, String, int)usingCriteriaSpecification.INNER_JOINfor the joinType.- Specified by:
createCriteriain interfaceCriteria- Parameters:
associationPath- A dot-seperated property pathalias- The alias to assign to the joined association (for later reference).- Returns:
- the created "sub criteria"
-
createCriteria
Description copied from interface:CriteriaCreate a new Criteria, "rooted" at the associated entity, assigning the given alias and using the specified join type.- Specified by:
createCriteriain interfaceCriteria- Parameters:
associationPath- A dot-seperated property pathalias- The alias to assign to the joined association (for later reference).joinType- The type of join to use.- Returns:
- the created "sub criteria"
-
createCriteria
public Criteria createCriteria(String associationPath, String alias, int joinType, Criterion withClause) Description copied from interface:CriteriaCreate a new Criteria, "rooted" at the associated entity, assigning the given alias and using the specified join type.- Specified by:
createCriteriain interfaceCriteria- Parameters:
associationPath- A dot-seperated property pathalias- 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"
-
getResultTransformer
-
setResultTransformer
Description copied from interface:CriteriaSet a strategy for handling the query results. This determines the "shape" of the query result.- Specified by:
setResultTransformerin interfaceCriteria- Parameters:
tupleMapper- The transformer to apply- Returns:
- this (for method chaining)
- See Also:
-
getMaxResults
-
setMaxResults
Description copied from interface:CriteriaSet a limit upon the number of objects to be retrieved.- Specified by:
setMaxResultsin interfaceCriteria- Parameters:
maxResults- the maximum number of results- Returns:
- this (for method chaining)
-
getFirstResult
-
setFirstResult
Description copied from interface:CriteriaSet the first result to be retrieved.- Specified by:
setFirstResultin interfaceCriteria- Parameters:
firstResult- the first result to retrieve, numbered from 0- Returns:
- this (for method chaining)
-
getFetchSize
-
setFetchSize
Description copied from interface:CriteriaSet a fetch size for the underlying JDBC query.- Specified by:
setFetchSizein interfaceCriteria- Parameters:
fetchSize- the fetch size- Returns:
- this (for method chaining)
- See Also:
-
getTimeout
-
setTimeout
Description copied from interface:CriteriaSet a timeout for the underlying JDBC query.- Specified by:
setTimeoutin interfaceCriteria- Parameters:
timeout- The timeout value to apply.- Returns:
- this (for method chaining)
- See Also:
-
isReadOnlyInitialized
public boolean isReadOnlyInitialized()Was the read-only/modifiable mode explicitly initialized?- Specified by:
isReadOnlyInitializedin interfaceCriteria- Returns:
- true, the read-only/modifiable mode was explicitly initialized; false, otherwise.
- See Also:
-
isReadOnly
public 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.- Specified by:
isReadOnlyin interfaceCriteria- 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:
-
setReadOnly
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:
setReadOnlyin interfaceCriteria- 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:
-
getCacheable
public boolean getCacheable() -
setCacheable
Description copied from interface:CriteriaEnable caching of this query result, provided query caching is enabled for the underlying session factory.- Specified by:
setCacheablein interfaceCriteria- Parameters:
cacheable- Should the result be considered cacheable; default is to not cache (false).- Returns:
- this (for method chaining)
-
getCacheRegion
-
setCacheRegion
Description copied from interface:CriteriaSet the name of the cache region to use for query result caching.- Specified by:
setCacheRegionin interfaceCriteria- Parameters:
cacheRegion- the name of a query cache region, or null for the default query cache- Returns:
- this (for method chaining)
- See Also:
-
getComment
-
setComment
Description copied from interface:CriteriaAdd a comment to the generated SQL.- Specified by:
setCommentin interfaceCriteria- Parameters:
comment- a human-readable string- Returns:
- this (for method chaining)
-
setFlushMode
Description copied from interface:CriteriaOverride the flush mode for this particular query.- Specified by:
setFlushModein interfaceCriteria- Parameters:
flushMode- The flush mode to use.- Returns:
- this (for method chaining)
-
setCacheMode
Description copied from interface:CriteriaOverride the cache mode for this particular query.- Specified by:
setCacheModein interfaceCriteria- Parameters:
cacheMode- The cache mode to use.- Returns:
- this (for method chaining)
-
list
Description copied from interface:CriteriaGet the results.- Specified by:
listin interfaceCriteria- 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
Description copied from interface:CriteriaGet the results as an instance ofScrollableResults- Specified by:
scrollin interfaceCriteria- Returns:
- The
ScrollableResultsrepresenting the matched query results.
-
scroll
Description copied from interface:CriteriaGet the results as an instance ofScrollableResultsbased on the given scroll mode.- Specified by:
scrollin interfaceCriteria- Parameters:
scrollMode- Indicates the type of underlying database cursor to request.- Returns:
- The
ScrollableResultsrepresenting the matched query results.
-
uniqueResult
Description copied from interface:CriteriaConvenience method to return a single instance that matches the query, or null if the query returns no results.- Specified by:
uniqueResultin interfaceCriteria- Returns:
- the single result or null
- Throws:
HibernateException- if there is more than one matching result
-
before
protected void before() -
after
protected void after() -
isLookupByNaturalKey
public boolean isLookupByNaturalKey()
-