Wraps the Hibernate Criteria API in a builder. The builder can be retrieved through the "createCriteria()" dynamic static method of Grails domain classes (Example in Groovy):
def c = Account.createCriteria() def results = c { projections { groupProperty("branch") } like("holderFirstName", "Fred%") and { between("balance", 500, 1000) eq("branch", "London") } maxResults(10) order("holderLastName", "desc") }
The builder can also be instantiated standalone with a SessionFactory and persistent Class instance:
new HibernateCriteriaBuilder(clazz, sessionFactory).list { eq("firstName", "Fred") }
Modifiers | Name | Description |
---|---|---|
static org.hibernate.type.Type |
BIG_DECIMAL |
|
static org.hibernate.type.Type |
BIG_INTEGER |
|
static org.hibernate.type.Type |
BINARY |
|
static org.hibernate.type.Type |
BLOB |
|
static org.hibernate.type.Type |
BOOLEAN |
|
static org.hibernate.type.Type |
BYTE |
|
static org.hibernate.type.Type |
CALENDAR |
|
static org.hibernate.type.Type |
CALENDAR_DATE |
|
static org.hibernate.type.Type |
CHARACTER |
|
static org.hibernate.type.Type |
CHARACTER_ARRAY |
|
static org.hibernate.type.Type |
CHAR_ARRAY |
|
static org.hibernate.type.Type |
CLASS |
|
static org.hibernate.type.Type |
CLOB |
|
static org.hibernate.type.Type |
CURRENCY |
|
static org.hibernate.type.Type |
DATE |
|
static org.hibernate.type.Type |
DOUBLE |
|
static org.hibernate.type.Type |
FLOAT |
|
static org.hibernate.type.Type |
IMAGE |
|
static org.hibernate.type.Type |
INTEGER |
|
static org.hibernate.type.Type |
LOCALE |
|
static org.hibernate.type.Type |
LONG |
|
static org.hibernate.type.Type |
MATERIALIZED_BLOB |
|
static org.hibernate.type.Type |
MATERIALIZED_CLOB |
|
static org.hibernate.type.Type |
NUMERIC_BOOLEAN |
|
static org.hibernate.type.Type |
SERIALIZABLE |
|
static org.hibernate.type.Type |
SHORT |
|
static org.hibernate.type.Type |
STRING |
|
static org.hibernate.type.Type |
TEXT |
|
static org.hibernate.type.Type |
TIME |
|
static org.hibernate.type.Type |
TIMESTAMP |
|
static org.hibernate.type.Type |
TIMEZONE |
|
static org.hibernate.type.Type |
TRUE_FALSE |
|
static org.hibernate.type.Type |
URL |
|
static org.hibernate.type.Type |
UUID_BINARY |
|
static org.hibernate.type.Type |
UUID_CHAR |
|
static org.hibernate.type.Type |
WRAPPER_BINARY |
|
static org.hibernate.type.Type |
YES_NO |
Fields inherited from class | Fields |
---|---|
class AbstractHibernateCriteriaBuilder |
AND, IS_NULL, IS_NOT_NULL, NOT, OR, ID_EQUALS, IS_EMPTY, IS_NOT_EMPTY, RLIKE, BETWEEN, EQUALS, EQUALS_PROPERTY, GREATER_THAN, GREATER_THAN_PROPERTY, GREATER_THAN_OR_EQUAL, GREATER_THAN_OR_EQUAL_PROPERTY, ILIKE, IN, LESS_THAN, LESS_THAN_PROPERTY, LESS_THAN_OR_EQUAL, LESS_THAN_OR_EQUAL_PROPERTY, LIKE, NOT_EQUAL, NOT_EQUAL_PROPERTY, SIZE_EQUALS, ORDER_DESCENDING, ORDER_ASCENDING |
Constructor and description |
---|
HibernateCriteriaBuilder
(java.lang.Class targetClass, org.hibernate.SessionFactory sessionFactory) |
HibernateCriteriaBuilder
(java.lang.Class targetClass, org.hibernate.SessionFactory sessionFactory, boolean uniqueResult) |
Type | Name and description |
---|---|
protected void |
cacheCriteriaMapping() |
protected org.hibernate.criterion.DetachedCriteria |
convertToHibernateCriteria(QueryableCriteria<?> queryableCriteria) |
org.hibernate.Criteria |
createAlias(java.lang.String associationPath, java.lang.String alias, int joinType) Join an association using the specified join-type, assigning an alias to the joined association. |
protected void |
createCriteriaInstance() |
protected java.util.List |
createPagedResultList(java.util.Map args) |
protected java.lang.Object |
executeUniqueResultWithProxyUnwrap() |
protected java.lang.Class |
getClassForAssociationType(org.hibernate.type.AssociationType type) |
static org.hibernate.criterion.DetachedCriteria |
getHibernateDetachedCriteria(AbstractHibernateQuery query, QueryableCriteria<?> queryableCriteria) |
Criteria |
rlike(java.lang.String propertyName, java.lang.Object propertyValue) Creates a Criterion with from the specified property name and "rlike" (a regular expression version of "like") expression |
Methods inherited from class | Name |
---|---|
class AbstractHibernateCriteriaBuilder |
lock, get, cache, cache, count, count, count, min, min, max, max, isEmpty, join, lt, getInstance, in, in, in, in, list, list, exists, sum, sum, eq, eq, eq, isNull, order, order, order, order, and, or, id, isNotEmpty, ne, ge, invokeMethod, property, property, gt, le, readOnly, readOnly, select, distinct, distinct, distinct, distinct, distinct, between, not, createAlias, createAlias, notEqual, resultTransformer, fetchMode, setConversionService, scroll, setDatastore, avg, avg, getTargetClass, countDistinct, countDistinct, groupProperty, groupProperty, rowCount, rowCount, eqProperty, neProperty, gtProperty, geProperty, ltProperty, leProperty, allEq, eqAll, eqAll, gtAll, gtAll, ltAll, ltAll, geAll, geAll, leAll, leAll, gtSome, gtSome, geSome, geSome, ltSome, ltSome, leSome, leSome, inList, inList, inList, inList, notIn, notIn, lte, idEquals, notExists, isNotNull, idEq, sqlRestriction, sqlRestriction, like, rlike, ilike, sizeEq, sizeGt, sizeGe, sizeLe, sizeLt, sizeNe, gte, listDistinct, buildCriteria, setUniqueResult, getDefaultFlushMode, setDefaultFlushMode, setProperty, getProperty, setMetaClass, getMetaClass, wait, wait, wait, equals, toString, hashCode, getClass, notify, notifyAll |
class groovy.lang.GroovyObjectSupport |
groovy.lang.GroovyObjectSupport#setProperty(java.lang.String, java.lang.Object), groovy.lang.GroovyObjectSupport#getProperty(java.lang.String), groovy.lang.GroovyObjectSupport#invokeMethod(java.lang.String, java.lang.Object), groovy.lang.GroovyObjectSupport#setMetaClass(groovy.lang.MetaClass), groovy.lang.GroovyObjectSupport#getMetaClass(), groovy.lang.GroovyObjectSupport#wait(long, int), groovy.lang.GroovyObjectSupport#wait(long), groovy.lang.GroovyObjectSupport#wait(), groovy.lang.GroovyObjectSupport#equals(java.lang.Object), groovy.lang.GroovyObjectSupport#toString(), groovy.lang.GroovyObjectSupport#hashCode(), groovy.lang.GroovyObjectSupport#getClass(), groovy.lang.GroovyObjectSupport#notify(), groovy.lang.GroovyObjectSupport#notifyAll() |
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), 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.Creates a Criterion with from the specified property name and "rlike" (a regular expression version of "like") expression
propertyName
- The property namepropertyValue
- The ilike value