public class CriteriaImpl extends Object implements Criteria, Serializable
| Modifier and Type | Class and Description |
|---|---|
static class |
CriteriaImpl.CriterionEntry |
static class |
CriteriaImpl.OrderEntry |
class |
CriteriaImpl.Subcriteria |
ALIAS_TO_ENTITY_MAP, DISTINCT_ROOT_ENTITY, FULL_JOIN, INNER_JOIN, LEFT_JOIN, PROJECTION, ROOT_ALIAS, ROOT_ENTITY| Constructor and Description |
|---|
CriteriaImpl(String entityOrClassName,
SessionImplementor session) |
CriteriaImpl(String entityOrClassName,
String alias,
SessionImplementor session) |
| Modifier and Type | Method and Description |
|---|---|
Criteria |
add(Criteria criteriaInst,
Criterion expression) |
Criteria |
add(Criterion expression)
Add a
restriction to constrain the results to be
retrieved. |
Criteria |
addOrder(Order ordering)
Add an
ordering 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 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 |
createAlias(String associationPath,
String alias,
JoinType joinType)
Join an association using the specified join-type, assigning an alias
to the joined association.
|
Criteria |
createAlias(String associationPath,
String alias,
JoinType 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,
JoinType 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.
|
Criteria |
createCriteria(String associationPath,
String alias,
JoinType 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,
JoinType 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.
|
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() |
SessionImplementor |
getSession() |
Integer |
getTimeout() |
boolean |
isLookupByNaturalKey() |
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?
|
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 based on the
given scroll mode. |
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 tupleMapper)
Set a strategy for handling the query results.
|
void |
setSession(SessionImplementor 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.
|
public CriteriaImpl(String entityOrClassName, SessionImplementor session)
public CriteriaImpl(String entityOrClassName, String alias, SessionImplementor session)
public SessionImplementor getSession()
public void setSession(SessionImplementor session)
public String getEntityOrClassName()
public Map getLockModes()
public Criteria getProjectionCriteria()
public Iterator iterateSubcriteria()
public Iterator iterateExpressionEntries()
public Iterator iterateOrderings()
public String getAlias()
Criteriapublic Projection getProjection()
public Criteria setProjection(Projection projection)
CriteriaCriteriaSpecification.PROJECTION result transformer.
The individual components contained within the given
projection determines the overall "shape" of the
query result.setProjection in interface Criteriaprojection - The projection representing the overall "shape" of the
query results.public Criteria add(Criterion expression)
Criteriarestriction to constrain the results to be
retrieved.public Criteria addOrder(Order ordering)
Criteriaordering to the result set.public Criteria setFetchMode(String associationPath, FetchMode mode)
CriteriasetFetchMode in interface CriteriaassociationPath - a dot seperated property pathmode - The fetch mode for the referenced associationpublic Criteria setLockMode(LockMode lockMode)
CriteriasetLockMode in interface CriterialockMode - The lock mode to be appliedpublic Criteria setLockMode(String alias, LockMode lockMode)
CriteriasetLockMode in interface Criteriaalias - The previously assigned alias representing the entity to
which the given lock mode should apply.lockMode - The lock mode to be appliedpublic Criteria createAlias(String associationPath, String alias)
CriteriaCriteria.createAlias(String, String, JoinType ) using
JoinType.INNER_JOIN for the joinType.createAlias in interface CriteriaassociationPath - A dot-seperated property pathalias - The alias to assign to the joined association (for later reference).public Criteria createAlias(String associationPath, String alias, JoinType joinType)
CriteriaJoinType.INNER_JOIN (the default),
JoinType.FULL_JOIN, or JoinType.LEFT_OUTER_JOIN.createAlias in interface CriteriaassociationPath - A dot-seperated property pathalias - The alias to assign to the joined association (for later reference).joinType - The type of join to use.public Criteria createAlias(String associationPath, String alias, int joinType) throws HibernateException
CriteriaCriteriaSpecification.INNER_JOIN (the default),
CriteriaSpecification.FULL_JOIN, or CriteriaSpecification.LEFT_JOIN.createAlias in interface CriteriaassociationPath - A dot-seperated property pathalias - The alias to assign to the joined association (for later reference).joinType - The type of join to use.HibernateException - Indicates a problem creating the sub criteriapublic Criteria createAlias(String associationPath, String alias, JoinType joinType, Criterion withClause)
CriteriaJoinType.INNER_JOIN (the default),
JoinType.FULL_JOIN, or JoinType.LEFT_OUTER_JOIN.createAlias in interface CriteriaassociationPath - 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)public Criteria createAlias(String associationPath, String alias, int joinType, Criterion withClause) throws HibernateException
CriteriaCriteriaSpecification.INNER_JOIN (the default),
CriteriaSpecification.FULL_JOIN, or CriteriaSpecification.LEFT_JOIN.createAlias in interface CriteriaassociationPath - 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)HibernateException - Indicates a problem creating the sub criteriapublic Criteria createCriteria(String associationPath)
CriteriaCriteria.createCriteria(String, org.hibernate.sql.JoinType) using
JoinType.INNER_JOIN for the joinType.createCriteria in interface CriteriaassociationPath - A dot-seperated property pathpublic Criteria createCriteria(String associationPath, JoinType joinType)
CriteriacreateCriteria in interface CriteriaassociationPath - A dot-seperated property pathjoinType - The type of join to use.public Criteria createCriteria(String associationPath, int joinType) throws HibernateException
CriteriacreateCriteria in interface CriteriaassociationPath - A dot-seperated property pathjoinType - The type of join to use.HibernateException - Indicates a problem creating the sub criteriapublic Criteria createCriteria(String associationPath, String alias)
CriteriaCriteria.createCriteria(String, String, org.hibernate.sql.JoinType) using
JoinType.INNER_JOIN for the joinType.createCriteria in interface CriteriaassociationPath - A dot-seperated property pathalias - The alias to assign to the joined association (for later reference).public Criteria createCriteria(String associationPath, String alias, JoinType joinType)
CriteriacreateCriteria in interface CriteriaassociationPath - A dot-seperated property pathalias - The alias to assign to the joined association (for later reference).joinType - The type of join to use.public Criteria createCriteria(String associationPath, String alias, int joinType) throws HibernateException
CriteriacreateCriteria in interface CriteriaassociationPath - A dot-seperated property pathalias - The alias to assign to the joined association (for later reference).joinType - The type of join to use.HibernateException - Indicates a problem creating the sub criteriapublic Criteria createCriteria(String associationPath, String alias, JoinType joinType, Criterion withClause)
CriteriacreateCriteria in interface CriteriaassociationPath - 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)public Criteria createCriteria(String associationPath, String alias, int joinType, Criterion withClause) throws HibernateException
CriteriacreateCriteria in interface CriteriaassociationPath - 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)HibernateException - Indicates a problem creating the sub criteriapublic ResultTransformer getResultTransformer()
public Criteria setResultTransformer(ResultTransformer tupleMapper)
CriteriasetResultTransformer in interface CriteriatupleMapper - The transformer to applyCriteriaSpecification.ROOT_ENTITY,
CriteriaSpecification.DISTINCT_ROOT_ENTITY,
CriteriaSpecification.ALIAS_TO_ENTITY_MAP,
CriteriaSpecification.PROJECTIONpublic Integer getMaxResults()
public Criteria setMaxResults(int maxResults)
CriteriasetMaxResults in interface CriteriamaxResults - the maximum number of resultspublic Integer getFirstResult()
public Criteria setFirstResult(int firstResult)
CriteriasetFirstResult in interface CriteriafirstResult - the first result to retrieve, numbered from 0public Integer getFetchSize()
public Criteria setFetchSize(int fetchSize)
CriteriasetFetchSize in interface CriteriafetchSize - the fetch sizeStatement.setFetchSize(int)public Integer getTimeout()
public Criteria setTimeout(int timeout)
CriteriasetTimeout in interface Criteriatimeout - The timeout value to apply.Statement.setQueryTimeout(int)public boolean isReadOnlyInitialized()
isReadOnlyInitialized in interface CriteriaCriteria.setReadOnly(boolean)public boolean isReadOnly()
isReadOnly in interface CriteriaCriteria.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()public Criteria setReadOnly(boolean readOnly)
setReadOnly in interface CriteriareadOnly - 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 modethis, for method chainingTo 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.public boolean getCacheable()
public Criteria setCacheable(boolean cacheable)
CriteriasetCacheable in interface Criteriacacheable - Should the result be considered cacheable; default is
to not cache (false).public String getCacheRegion()
public Criteria setCacheRegion(String cacheRegion)
CriteriasetCacheRegion in interface CriteriacacheRegion - the name of a query cache region, or null
for the default query cacheCriteria.setCacheable(boolean)public String getComment()
public Criteria setComment(String comment)
CriteriasetComment in interface Criteriacomment - a human-readable stringpublic Criteria setFlushMode(FlushMode flushMode)
CriteriasetFlushMode in interface CriteriaflushMode - The flush mode to use.public Criteria setCacheMode(CacheMode cacheMode)
CriteriasetCacheMode in interface CriteriacacheMode - The cache mode to use.public List list() throws HibernateException
Criterialist in interface CriteriaHibernateException - Indicates a problem either translating the criteria to SQL,
exeucting the SQL or processing the SQL results.public ScrollableResults scroll()
CriteriaScrollableResultsscroll in interface CriteriaScrollableResults representing the matched
query results.public ScrollableResults scroll(ScrollMode scrollMode)
CriteriaScrollableResults based on the
given scroll mode.scroll in interface CriteriascrollMode - Indicates the type of underlying database cursor to
request.ScrollableResults representing the matched
query results.public Object uniqueResult() throws HibernateException
CriteriauniqueResult in interface CriteriaHibernateException - if there is more than one matching resultprotected void before()
protected void after()
public boolean isLookupByNaturalKey()
Copyright © 2012 JBoss by Red Hat. All Rights Reserved.