public class HibernateCriteriaBuilder extends AbstractHibernateCriteriaBuilder
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 |
Constructor and description |
---|
HibernateCriteriaBuilder(java.lang.Class targetClass, org.hibernate.SessionFactory sessionFactory) |
HibernateCriteriaBuilder(java.lang.Class targetClass, org.hibernate.SessionFactory sessionFactory, boolean uniqueResult) |
Type Params | Return Type | Name and description |
---|---|---|
|
protected void |
cacheCriteriaMapping() |
|
protected void |
closeSession() Closes the session if it is copen |
|
protected org.hibernate.criterion.DetachedCriteria |
convertToHibernateCriteria(QueryableCriteria<?> queryableCriteria) |
|
public 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(jakarta.persistence.metamodel.Attribute<?, ?> type) |
|
public static org.hibernate.criterion.DetachedCriteria |
getHibernateDetachedCriteria(AbstractHibernateQuery query, QueryableCriteria<?> queryableCriteria) |
|
public static org.hibernate.criterion.DetachedCriteria |
getHibernateDetachedCriteria(AbstractHibernateQuery query, QueryableCriteria<?> queryableCriteria, java.lang.String alias) |
|
public 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 |
Closes the session if it is copen
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