public abstract class AbstractHibernateCriteriaBuilder extends GroovyObjectSupport implements BuildableCriteria, org.grails.datastore.mapping.query.apiProjectionList
Abstract super class for sharing code between Hibernate 3 and 4 implementations of HibernateCriteriaBuilder
| Modifiers | Name | Description |
|---|---|---|
protected class |
AbstractHibernateCriteriaBuilder.LogicalExpression |
instances of this class are pushed onto the logicalExpressionStack to represent all the unfinished "and", "or", and "not" expressions. |
| Constructor and description |
|---|
AbstractHibernateCriteriaBuilder(Class targetClass, SessionFactory sessionFactory) |
AbstractHibernateCriteriaBuilder(Class targetClass, SessionFactory sessionFactory, boolean uniqueResult) |
| Type Params | Return Type | Name and description |
|---|---|---|
|
protected void |
addProjectionToList(Projection propertyProjection, String alias)Adds a projection to the projectList for the given alias |
|
protected Criterion |
addToCriteria(Criterion c)adds and returns the given criterion to the currently active criteria set. |
|
public Criteria |
allEq(Map<String, Object> propertyValues) |
|
public Criteria |
and(Closure callable) |
|
public ProjectionList |
avg(String propertyName)Adds a projection that allows the criteria to return the property average value |
|
public ProjectionList |
avg(String propertyName, String alias)Adds a projection that allows the criteria to return the property average value |
|
public Criteria |
between(String propertyName, Object lo, Object hi)Creates a "between" Criterion based on the property name and specified lo and hi values |
|
public Criteria |
buildCriteria(Closure<?> criteriaClosure) |
|
public BuildableCriteria |
cache(boolean shouldCache)Whether to use the query cache |
|
protected abstract void |
cacheCriteriaMapping() |
|
protected String |
calculatePropertyName(String propertyName)Calculates the property name including any alias paths |
|
protected Object |
calculatePropertyValue(Object propertyValue)Calculates the property value, converting GStrings if necessary |
|
protected void |
closeSession()Closes the session if it is copen |
|
protected List |
convertArgumentList(List argList) |
|
protected Order |
convertOrder(Query.Order o, String property) |
|
protected abstract DetachedCriteria |
convertToHibernateCriteria(QueryableCriteria<?> queryableCriteria) |
|
public void |
count(String propertyName)Adds a projection that allows the criteria to return the property count |
|
public void |
count(String propertyName, String alias)Adds a projection that allows the criteria to return the property count |
|
public ProjectionList |
count() |
|
public ProjectionList |
countDistinct(String propertyName)Adds a projection that allows the criteria to return the distinct property count |
|
public ProjectionList |
countDistinct(String propertyName, String alias)Adds a projection that allows the criteria to return the distinct property count |
|
public Criteria |
createAlias(String associationPath, String alias)Join an association, assigning an alias to the joined association. |
|
public abstract Criteria |
createAlias(String associationPath, String alias, int joinType)Join an association using the specified join-type, assigning an alias to the joined association. |
|
protected abstract void |
createCriteriaInstance() |
|
protected abstract List |
createPagedResultList(Map args) |
|
public ProjectionList |
distinct(String propertyName)A projection that selects a distince property name |
|
public ProjectionList |
distinct(String propertyName, String alias)A projection that selects a distince property name |
|
public ProjectionList |
distinct(Collection propertyNames)A distinct projection that takes a list |
|
public ProjectionList |
distinct(Collection propertyNames, String alias)A distinct projection that takes a list |
|
public ProjectionList |
distinct() |
|
public Criteria |
eq(String propertyName, Object propertyValue)Creates an "equals" Criterion based on the specified property name and value. |
|
public Criteria |
eq(Map params, String propertyName, Object propertyValue)Groovy moves the map to the first parameter if using the idiomatic form, e.g. |
|
public Criteria |
eq(String propertyName, Object propertyValue, Map params)Creates an "equals" Criterion based on the specified property name and value. |
|
public Criteria |
eqAll(String propertyName, Closure<?> propertyValue)Creates a subquery criterion that ensures the given property is equal to all the given returned values |
|
public Criteria |
eqAll(String propertyName, QueryableCriteria propertyValue)Creates a subquery criterion that ensures the given property is equal to all the given returned values |
|
public Criteria |
eqProperty(String propertyName, String otherPropertyName)Creates a Criterion that compares to class properties for equality |
|
protected Criteria |
executeLogicalExpression(Closure callable, String logicalOperator) |
|
protected abstract Object |
executeUniqueResultWithProxyUnwrap() |
|
public Criteria |
exists(QueryableCriteria<?> subquery) |
|
public void |
fetchMode(String associationPath, FetchMode fetchMode)Sets the fetch mode of an associated path |
|
public Criteria |
ge(String propertyName, Object propertyValue)Creates a "greater than or equal to" Criterion based on the specified property name and value |
|
public Criteria |
geAll(String propertyName, Closure<?> propertyValue)Creates a subquery criterion that ensures the given property is greater than all the given returned values |
|
public Criteria |
geAll(String propertyName, QueryableCriteria propertyValue)Creates a subquery criterion that ensures the given property is greater than all the given returned values |
|
public Criteria |
geProperty(String propertyName, String otherPropertyName)Creates a Criterion that tests if the first property is greater than or equal to the second property |
|
public Criteria |
geSome(String propertyName, QueryableCriteria propertyValue) |
|
public Criteria |
geSome(String propertyName, Closure<?> propertyValue) |
|
public Object |
get(Closure c) |
|
protected abstract Class |
getClassForAssociationType(Attribute<?, ?> type) |
|
public int |
getDefaultFlushMode() |
|
public Criteria |
getInstance()Returns the criteria instance |
|
public Class<?> |
getTargetClass() |
|
public ProjectionList |
groupProperty(String propertyName)Adds a projection that allows the criteria to return the distinct property count |
|
public ProjectionList |
groupProperty(String propertyName, String alias)Adds a projection that allows the criteria's result to be grouped by a property |
|
public Criteria |
gt(String propertyName, Object propertyValue)Creates a "greater than" Criterion based on the specified property name and value |
|
public Criteria |
gtAll(String propertyName, Closure<?> propertyValue)Creates a subquery criterion that ensures the given property is greater than all the given returned values |
|
public Criteria |
gtAll(String propertyName, QueryableCriteria propertyValue)Creates a subquery criterion that ensures the given property is greater than all the given returned values |
|
public Criteria |
gtProperty(String propertyName, String otherPropertyName)Creates a Criterion that tests if the first property is greater than the second property |
|
public Criteria |
gtSome(String propertyName, QueryableCriteria propertyValue) |
|
public Criteria |
gtSome(String propertyName, Closure<?> propertyValue) |
|
public Criteria |
gte(String s, Object o) |
|
public ProjectionList |
id() |
|
public Criteria |
idEq(Object o) |
|
public Criteria |
idEquals(Object o) |
|
public Criteria |
ilike(String propertyName, Object propertyValue)Creates a Criterion with from the specified property name and "ilike" (a case sensitive version of "like") expression |
|
public Criteria |
in(String propertyName, QueryableCriteria<?> subquery) |
|
public Criteria |
in(String propertyName, Closure<?> subquery) |
|
public Criteria |
in(String propertyName, Collection values)Applys a "in" contrain on the specified property |
|
public Criteria |
in(String propertyName, Object[] values)Applys a "in" contrain on the specified property |
|
public Criteria |
inList(String propertyName, QueryableCriteria<?> subquery) |
|
public Criteria |
inList(String propertyName, Closure<?> subquery) |
|
public Criteria |
inList(String propertyName, Collection values)Delegates to in as in is a Groovy keyword |
|
public Criteria |
inList(String propertyName, Object[] values)Delegates to in as in is a Groovy keyword |
|
public Object |
invokeMethod(String name, Object obj) |
|
public Criteria |
isEmpty(String property) |
|
public Criteria |
isNotEmpty(String property) |
|
public Criteria |
isNotNull(String property) |
|
public Criteria |
isNull(String property) |
|
public BuildableCriteria |
join(String associationPath)Use a join query |
|
public BuildableCriteria |
join(String property, JoinType joinType) |
|
public Criteria |
le(String propertyName, Object propertyValue)Creates a "less than or equal to" Criterion based on the specified property name and value |
|
public Criteria |
leAll(String propertyName, Closure<?> propertyValue)Creates a subquery criterion that ensures the given property is less than all the given returned values |
|
public Criteria |
leAll(String propertyName, QueryableCriteria propertyValue)Creates a subquery criterion that ensures the given property is less than all the given returned values |
|
public Criteria |
leProperty(String propertyName, String otherPropertyName)Creates a Criterion that tests if the first property is less than or equal to the second property |
|
public Criteria |
leSome(String propertyName, QueryableCriteria propertyValue) |
|
public Criteria |
leSome(String propertyName, Closure<?> propertyValue) |
|
public Criteria |
like(String propertyName, Object propertyValue)Creates a Criterion with from the specified property name and "like" expression |
|
public Object |
list(Closure c) |
|
public Object |
list(Map params, Closure c) |
|
public Object |
listDistinct(Closure c) |
|
public void |
lock(boolean shouldLock)Whether a pessimistic lock should be obtained. |
|
public Criteria |
lt(String propertyName, Object propertyValue)Creates a "less than" Criterion based on the specified property name and value |
|
public Criteria |
ltAll(String propertyName, Closure<?> propertyValue)Creates a subquery criterion that ensures the given property is less than all the given returned values |
|
public Criteria |
ltAll(String propertyName, QueryableCriteria propertyValue)Creates a subquery criterion that ensures the given property is less than all the given returned values |
|
public Criteria |
ltProperty(String propertyName, String otherPropertyName)Creates a Criterion that tests if the first property is less than the second property |
|
public Criteria |
ltSome(String propertyName, QueryableCriteria propertyValue) |
|
public Criteria |
ltSome(String propertyName, Closure<?> propertyValue) |
|
public Criteria |
lte(String s, Object o) |
|
public ProjectionList |
max(String propertyName)Adds a projection that allows the criteria to retrieve a maximum property value |
|
public ProjectionList |
max(String propertyName, String alias)Adds a projection that allows the criteria to retrieve a maximum property value |
|
public ProjectionList |
min(String propertyName)Adds a projection that allows the criteria to retrieve a minimum property value |
|
public ProjectionList |
min(String propertyName, String alias)Adds a projection that allows the criteria to retrieve a minimum property value |
|
public Criteria |
ne(String propertyName, Object propertyValue)Creates a "not equal" Criterion based on the specified property name and value |
|
public Criteria |
neProperty(String propertyName, String otherPropertyName)Creates a Criterion that compares to class properties for ! |
|
public Criteria |
not(Closure callable) |
|
public Criteria |
notEqual(String propertyName, Object propertyValue) |
|
public Criteria |
notExists(QueryableCriteria<?> subquery) |
|
public Criteria |
notIn(String propertyName, QueryableCriteria<?> subquery) |
|
public Criteria |
notIn(String propertyName, Closure<?> subquery) |
|
public Criteria |
or(Closure callable) |
|
public Criteria |
order(String propertyName)Orders by the specified property name (defaults to ascending) |
|
public Criteria |
order(Order o)Orders by the specified property name (defaults to ascending) |
|
public Criteria |
order(Query.Order o) |
|
public Criteria |
order(String propertyName, String direction)Orders by the specified property name and direction |
|
public ProjectionList |
property(String propertyName)A projection that selects a property name |
|
public ProjectionList |
property(String propertyName, String alias)A projection that selects a property name |
|
public BuildableCriteria |
readOnly(boolean readOnly)Whether to check for changes on the objects loaded |
|
public void |
resultTransformer(ResultTransformer transformer)Sets the resultTransformer. |
|
public abstract Criteria |
rlike(String propertyName, Object propertyValue)Creates a Criterion with from the specified property name and "rlike" (a regular expression version of "like") expression |
|
public ProjectionList |
rowCount()Adds a projection that allows the criteria to return the row count |
|
public ProjectionList |
rowCount(String alias)Adds a projection that allows the criteria to return the row count |
|
public Object |
scroll(Closure c) |
|
public BuildableCriteria |
select(String associationPath)Use a select query |
|
public void |
setConversionService(ConversionService conversionService) |
|
public void |
setDatastore(AbstractHibernateDatastore datastore) |
|
public void |
setDefaultFlushMode(int defaultFlushMode) |
|
public void |
setUniqueResult(boolean uniqueResult)Set whether a unique result should be returned |
|
public Criteria |
sizeEq(String propertyName, int size)Creates a Criterion that contrains a collection property by size |
|
public Criteria |
sizeGe(String propertyName, int size)Creates a Criterion that contrains a collection property to be greater than or equal to the given size |
|
public Criteria |
sizeGt(String propertyName, int size)Creates a Criterion that contrains a collection property to be greater than the given size |
|
public Criteria |
sizeLe(String propertyName, int size)Creates a Criterion that contrains a collection property to be less than or equal to the given size |
|
public Criteria |
sizeLt(String propertyName, int size)Creates a Criterion that contrains a collection property to be less than to the given size |
|
public Criteria |
sizeNe(String propertyName, int size)Creates a Criterion that contrains a collection property to be not equal to the given size |
|
protected void |
sqlGroupProjection(String sql, String groupBy, List<String> columnAliases, List<Type> types)Adds a sql projection to the criteria |
|
protected void |
sqlProjection(String sql, String columnAlias, Type type)Adds a sql projection to the criteria |
|
protected void |
sqlProjection(String sql, List<String> columnAliases, List<Type> types)Adds a sql projection to the criteria |
|
public Criteria |
sqlRestriction(String sqlRestriction)Applies a sql restriction to the results to allow something like: |
|
public Criteria |
sqlRestriction(String sqlRestriction, List<?> values)Applies a sql restriction to the results to allow something like: |
|
public ProjectionList |
sum(String propertyName)Adds a projection that allows the criteria to retrieve the sum of the results of a property |
|
public ProjectionList |
sum(String propertyName, String alias)Adds a projection that allows the criteria to retrieve the sum of the results of a property |
|
protected void |
throwRuntimeException(RuntimeException t)Throws a runtime exception where necessary to ensure the session gets closed |
|
protected boolean |
validateSimpleExpression() |
| Methods inherited from class | Name |
|---|---|
class GroovyObjectSupport |
equals, getClass, getMetaClass, getProperty, hashCode, invokeMethod, notify, notifyAll, setMetaClass, setProperty, toString, wait, wait, wait |
Adds a projection to the projectList for the given alias
propertyProjection - The projectionalias - The aliasadds and returns the given criterion to the currently active criteria set. this might be either the root criteria or a currently open LogicalExpression.
Adds a projection that allows the criteria to return the property average value
propertyName - The name of the propertyAdds a projection that allows the criteria to return the property average value
propertyName - The name of the propertyalias - The alias to useCreates a "between" Criterion based on the property name and specified lo and hi values
propertyName - The property namelo - The low valuehi - The high valueWhether to use the query cache
shouldCache - True if the query should be cachedCalculates the property name including any alias paths
propertyName - The property nameCalculates the property value, converting GStrings if necessary
propertyValue - The property valueCloses the session if it is copen
Adds a projection that allows the criteria to return the property count
propertyName - The name of the propertyAdds a projection that allows the criteria to return the property count
propertyName - The name of the propertyalias - The alias to useAdds a projection that allows the criteria to return the distinct property count
propertyName - The name of the propertyAdds a projection that allows the criteria to return the distinct property count
propertyName - The name of the propertyalias - The alias to useJoin an association, assigning an alias to the joined association.
Functionally equivalent to createAlias(String, String, int) using CriteriaSpecificationINNER_JOIN for the joinType.
associationPath - A dot-seperated property pathalias - The alias to assign to the joined association (for later reference).Join an association using the specified join-type, assigning an alias to the joined association. sub The joinType is expected to be one of CriteriaSpecification.INNER_JOIN (the default), CriteriaSpecificationFULL_JOIN, or CriteriaSpecificationLEFT_JOIN.
associationPath - A dot-seperated property pathalias - The alias to assign to the joined association (for later reference).joinType - The type of join to use.A projection that selects a distince property name
propertyName - The property nameA projection that selects a distince property name
propertyName - The property namealias - The alias to useA distinct projection that takes a list
propertyNames - The list of distince property namesA distinct projection that takes a list
propertyNames - The list of distince property namesalias - The alias to useCreates an "equals" Criterion based on the specified property name and value. Case-sensitive.
propertyName - The property namepropertyValue - The property value Groovy moves the map to the first parameter if using the idiomatic form, e.g.
eq 'firstName', 'Fred', ignoreCase: true.
params - optional map with customization parameters; currently only 'ignoreCase' is supported. Creates an "equals" Criterion based on the specified property name and value.
Supports case-insensitive search if the params map contains true
under the 'ignoreCase' key.
propertyName - The property namepropertyValue - The property valueparams - optional map with customization parameters; currently only 'ignoreCase' is supported.Creates a subquery criterion that ensures the given property is equal to all the given returned values
propertyName - The property namepropertyValue - The property valueCreates a subquery criterion that ensures the given property is equal to all the given returned values
propertyName - The property namepropertyValue - The property valueCreates a Criterion that compares to class properties for equality
propertyName - The first property nameotherPropertyName - The second property nameSets the fetch mode of an associated path
associationPath - The name of the associated pathfetchMode - The fetch mode to setCreates a "greater than or equal to" Criterion based on the specified property name and value
propertyName - The property namepropertyValue - The property valueCreates a subquery criterion that ensures the given property is greater than all the given returned values
propertyName - The property namepropertyValue - The property valueCreates a subquery criterion that ensures the given property is greater than all the given returned values
propertyName - The property namepropertyValue - The property valueCreates a Criterion that tests if the first property is greater than or equal to the second property
propertyName - The first property nameotherPropertyName - The second property nameReturns the criteria instance
Adds a projection that allows the criteria to return the distinct property count
propertyName - The name of the propertyAdds a projection that allows the criteria's result to be grouped by a property
propertyName - The name of the propertyalias - The alias to useCreates a "greater than" Criterion based on the specified property name and value
propertyName - The property namepropertyValue - The property valueCreates a subquery criterion that ensures the given property is greater than all the given returned values
propertyName - The property namepropertyValue - The property valueCreates a subquery criterion that ensures the given property is greater than all the given returned values
propertyName - The property namepropertyValue - The property valueCreates a Criterion that tests if the first property is greater than the second property
propertyName - The first property nameotherPropertyName - The second property nameCreates a Criterion with from the specified property name and "ilike" (a case sensitive version of "like") expression
propertyName - The property namepropertyValue - The ilike valueApplys a "in" contrain on the specified property
propertyName - The property namevalues - A collection of valuesApplys a "in" contrain on the specified property
propertyName - The property namevalues - A collection of valuesDelegates to in as in is a Groovy keyword
Delegates to in as in is a Groovy keyword
Use a join query
associationPath - The path of the associationCreates a "less than or equal to" Criterion based on the specified property name and value
propertyName - The property namepropertyValue - The property valueCreates a subquery criterion that ensures the given property is less than all the given returned values
propertyName - The property namepropertyValue - The property valueCreates a subquery criterion that ensures the given property is less than all the given returned values
propertyName - The property namepropertyValue - The property valueCreates a Criterion that tests if the first property is less than or equal to the second property
propertyName - The first property nameotherPropertyName - The second property nameCreates a Criterion with from the specified property name and "like" expression
propertyName - The property namepropertyValue - The like valueWhether a pessimistic lock should be obtained.
shouldLock - True if it shouldCreates a "less than" Criterion based on the specified property name and value
propertyName - The property namepropertyValue - The property valueCreates a subquery criterion that ensures the given property is less than all the given returned values
propertyName - The property namepropertyValue - The property valueCreates a subquery criterion that ensures the given property is less than all the given returned values
propertyName - The property namepropertyValue - The property valueCreates a Criterion that tests if the first property is less than the second property
propertyName - The first property nameotherPropertyName - The second property nameAdds a projection that allows the criteria to retrieve a maximum property value
propertyName - The name of the propertyAdds a projection that allows the criteria to retrieve a maximum property value
propertyName - The name of the propertyalias - The alias to useAdds a projection that allows the criteria to retrieve a minimum property value
propertyName - The name of the propertyAdds a projection that allows the criteria to retrieve a minimum property value
alias - The alias to useCreates a "not equal" Criterion based on the specified property name and value
propertyName - The property namepropertyValue - The property valueCreates a Criterion that compares to class properties for !equality
propertyName - The first property nameotherPropertyName - The second property nameOrders by the specified property name (defaults to ascending)
propertyName - The property name to order byOrders by the specified property name (defaults to ascending)
o - The property name to order byOrders by the specified property name and direction
propertyName - The property name to order bydirection - Either "asc" for ascending or "desc" for descendingA projection that selects a property name
propertyName - The name of the propertyA projection that selects a property name
propertyName - The name of the propertyalias - The alias to useWhether to check for changes on the objects loaded
readOnly - True to disable dirty checkingSets the resultTransformer.
transformer - The result transformer to use.Creates a Criterion with from the specified property name and "rlike" (a regular expression version of "like") expression
propertyName - The property namepropertyValue - The ilike valueAdds a projection that allows the criteria to return the row count
Adds a projection that allows the criteria to return the row count
alias - The alias to useUse a select query
associationPath - The path of the associationSet whether a unique result should be returned
uniqueResult - True if a unique result should be returnedCreates a Criterion that contrains a collection property by size
propertyName - The property namesize - The size to constrain byCreates a Criterion that contrains a collection property to be greater than or equal to the given size
propertyName - The property namesize - The size to constrain byCreates a Criterion that contrains a collection property to be greater than the given size
propertyName - The property namesize - The size to constrain byCreates a Criterion that contrains a collection property to be less than or equal to the given size
propertyName - The property namesize - The size to constrain byCreates a Criterion that contrains a collection property to be less than to the given size
propertyName - The property namesize - The size to constrain byCreates a Criterion that contrains a collection property to be not equal to the given size
propertyName - The property namesize - The size to constrain byAdds a sql projection to the criteria
sql - SQL projectinggroupBy - group by clausecolumnAliases - List of column aliases for the projected valuestypes - List of types for the projected valuesAdds a sql projection to the criteria
sql - SQL projecting a single valuecolumnAlias - column alias for the projected valuetype - the type of the projected valueAdds a sql projection to the criteria
sql - SQL projectingcolumnAliases - List of column aliases for the projected valuestypes - List of types for the projected valuesApplies a sql restriction to the results to allow something like:
sqlRestriction - the sql restrictionApplies a sql restriction to the results to allow something like:
sqlRestriction - the sql restrictionvalues - jdbc parametersAdds a projection that allows the criteria to retrieve the sum of the results of a property
propertyName - The name of the propertyAdds a projection that allows the criteria to retrieve the sum of the results of a property
propertyName - The name of the propertyalias - The alias to useThrows a runtime exception where necessary to ensure the session gets closed