Overview | Package | Class | Deprecated | Index | Help
| Groovy Documentation
| FRAMES NO FRAMES
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD

## grails.orm
[Java] Class HibernateCriteriaBuilder

    java.lang.Object
      groovy.lang.GroovyObjectSupport
          grails.orm.HibernateCriteriaBuilder

    public class HibernateCriteriaBuilder
    extends groovy.lang.GroovyObjectSupport

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")
          }

Authors:
  Graeme Rocher

Field Summary
`static java.lang.String` | `AND`
`static java.lang.String` | `BETWEEN`
`static java.lang.String` | `EQUALS`
`static java.lang.String` | `EQUALS_PROPERTY`
`static java.lang.String` | `GREATER_THAN`
`static java.lang.String` | `GREATER_THAN_OR_EQUAL`
`static java.lang.String` | `GREATER_THAN_OR_EQUAL_PROPERTY`
`static java.lang.String` | `GREATER_THAN_PROPERTY`
`static java.lang.String` | `ID_EQUALS`
`static java.lang.String` | `ILIKE`
`static java.lang.String` | `IN`
`static java.lang.String` | `IS_EMPTY`
`static java.lang.String` | `IS_NOT_EMPTY`
`static java.lang.String` | `IS_NOT_NULL`
`static java.lang.String` | `IS_NULL`
`static java.lang.String` | `LESS_THAN`
`static java.lang.String` | `LESS_THAN_OR_EQUAL`
`static java.lang.String` | `LESS_THAN_OR_EQUAL_PROPERTY`
`static java.lang.String` | `LESS_THAN_PROPERTY`
`static java.lang.String` | `LIKE`
`static java.lang.String` | `NOT`
`static java.lang.String` | `NOT_EQUAL`
`static java.lang.String` | `NOT_EQUAL_PROPERTY`
`static java.lang.String` | `OR`
`static java.lang.String` | `ORDER_ASCENDING`
`static java.lang.String` | `ORDER_DESCENDING`
`static java.lang.String` | `RLIKE`
`static java.lang.String` | `SIZE_EQUALS`

Constructor Summary
`HibernateCriteriaBuilder(java.lang.Class targetClass, SessionFactory sessionFactory)`
`HibernateCriteriaBuilder(java.lang.Class targetClass, SessionFactory sessionFactory, boolean uniqueResult)`

Method Summary
`protected void` | `addProjectionToList(Projection propertyProjection, java.lang.String alias)` Adds a projection to the projectList for the given alias
`void` | `avg(java.lang.String propertyName)` Adds a projection that allows the criteria to return the property average value
`void` | `avg(java.lang.String propertyName, java.lang.String alias)` Adds a projection that allows the criteria to return the property average value
`java.lang.Object` | `between(java.lang.String propertyName, java.lang.Object lo, java.lang.Object hi)` Creates a "between" Criterion based on the property name and specified lo and hi values
`Criteria` | `buildCriteria(groovy.lang.Closure criteriaClosure)`
`void` | `cache(boolean shouldCache)` Whether to use the query cache
`void` | `count(java.lang.String propertyName)` Adds a projection that allows the criteria to return the property count
`void` | `count(java.lang.String propertyName, java.lang.String alias)` Adds a projection that allows the criteria to return the property count
`void` | `countDistinct(java.lang.String propertyName)` Adds a projection that allows the criteria to return the distinct property count
`void` | `countDistinct(java.lang.String propertyName, java.lang.String alias)` Adds a projection that allows the criteria to return the distinct property count
`void` | `distinct(java.lang.String propertyName)` A projection that selects a distince property name
`void` | `distinct(java.lang.String propertyName, java.lang.String alias)` A projection that selects a distince property name
`void` | `distinct(java.util.Collection propertyNames)` A distinct projection that takes a list
`void` | `distinct(java.util.Collection propertyNames, java.lang.String alias)` A distinct projection that takes a list
`java.lang.Object` | `eq(java.lang.String propertyName, java.lang.Object propertyValue)` Creates an "equals" Criterion based on the specified property name and value.
`java.lang.Object` | `eq(java.util.Map params, java.lang.String propertyName, java.lang.Object propertyValue)` Groovy moves the map to the first parameter if using the idiomatic form, e.g.
`java.lang.Object` | `eq(java.lang.String propertyName, java.lang.Object propertyValue, java.util.Map params)` Creates an "equals" Criterion based on the specified property name and value.
`java.lang.Object` | `eqProperty(java.lang.String propertyName, java.lang.String otherPropertyName)` Creates a Criterion that compares to class properties for equality
`void` | `fetchMode(java.lang.String associationPath, FetchMode fetchMode)` Sets the fetch mode of an associated path
`java.lang.Object` | `ge(java.lang.String propertyName, java.lang.Object propertyValue)` Creates a "greater than or equal to" Criterion based on the specified property name and value
`java.lang.Object` | `geProperty(java.lang.String propertyName, java.lang.String otherPropertyName)` Creates a Criterion that tests if the first property is greater than or equal to the second property
`Criteria` | `getInstance()` Returns the criteria instance
`void` | `groupProperty(java.lang.String propertyName)` Adds a projection that allows the criteria's result to be grouped by a property
`void` | `groupProperty(java.lang.String propertyName, java.lang.String alias)` Adds a projection that allows the criteria's result to be grouped by a property
`java.lang.Object` | `gt(java.lang.String propertyName, java.lang.Object propertyValue)` Creates a "greater than" Criterion based on the specified property name and value
`java.lang.Object` | `gtProperty(java.lang.String propertyName, java.lang.String otherPropertyName)` Creates a Criterion that tests if the first property is greater than the second property
`java.lang.Object` | `ilike(java.lang.String propertyName, java.lang.Object propertyValue)` Creates a Criterion with from the specified property name and "ilike" (a case sensitive version of "like") expression
`java.lang.Object` | `in(java.lang.String propertyName, java.util.Collection values)` Applys a "in" contrain on the specified property
`java.lang.Object` | `in(java.lang.String propertyName, Object[] values)` Applys a "in" contrain on the specified property
`java.lang.Object` | `inList(java.lang.String propertyName, java.util.Collection values)` Delegates to in as in is a Groovy keyword
`java.lang.Object` | `inList(java.lang.String propertyName, Object[] values)` Delegates to in as in is a Groovy keyword
`java.lang.Object` | `invokeMethod(java.lang.String name, java.lang.Object obj)`
`void` | `join(java.lang.String associationPath)` Use a join query
`java.lang.Object` | `le(java.lang.String propertyName, java.lang.Object propertyValue)` Creates a "less than or equal to" Criterion based on the specified property name and value
`java.lang.Object` | `leProperty(java.lang.String propertyName, java.lang.String otherPropertyName)` Creates a Criterion that tests if the first property is less than or equal to the second property
`java.lang.Object` | `like(java.lang.String propertyName, java.lang.Object propertyValue)` Creates a Criterion with from the specified property name and "like" expression
`void` | `lock(boolean shouldLock)` Whether a pessimistic lock should be obtained.
`java.lang.Object` | `lt(java.lang.String propertyName, java.lang.Object propertyValue)` Creates a "less than" Criterion based on the specified property name and value
`java.lang.Object` | `ltProperty(java.lang.String propertyName, java.lang.String otherPropertyName)` Creates a Criterion that tests if the first property is less than the second property
`void` | `max(java.lang.String propertyName)` Adds a projection that allows the criteria to retrieve a maximum property value
`void` | `max(java.lang.String propertyName, java.lang.String alias)` Adds a projection that allows the criteria to retrieve a maximum property value
`void` | `min(java.lang.String propertyName)` Adds a projection that allows the criteria to retrieve a minimum property value
`void` | `min(java.lang.String propertyName, java.lang.String alias)` Adds a projection that allows the criteria to retrieve a minimum property value
`java.lang.Object` | `ne(java.lang.String propertyName, java.lang.Object propertyValue)` Creates a "not equal" Criterion based on the specified property name and value
`java.lang.Object` | `neProperty(java.lang.String propertyName, java.lang.String otherPropertyName)` Creates a Criterion that compares to class properties for !
`java.lang.Object` | `notEqual(java.lang.String propertyName, java.lang.Object propertyValue)`
`java.lang.Object` | `order(java.lang.String propertyName)` Orders by the specified property name (defaults to ascending)
`java.lang.Object` | `order(java.lang.String propertyName, java.lang.String direction)` Orders by the specified property name and direction
`void` | `property(java.lang.String propertyName)` A projection that selects a property name
`void` | `property(java.lang.String propertyName, java.lang.String alias)` A projection that selects a property name
`void` | `resultTransformer(ResultTransformer transformer)` Sets the resultTransformer.
`java.lang.Object` | `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
`void` | `rowCount()` Adds a projection that allows the criteria to return the row count
`void` | `rowCount(java.lang.String alias)` Adds a projection that allows the criteria to return the row count
`void` | `select(java.lang.String associationPath)` Use a select query
`void` | `setUniqueResult(boolean uniqueResult)` Set whether a unique result should be returned
`java.lang.Object` | `sizeEq(java.lang.String propertyName, int size)` Creates a Criterion that contrains a collection property by size
`java.lang.Object` | `sizeGe(java.lang.String propertyName, int size)` Creates a Criterion that contrains a collection property to be greater than or equal to the given size
`java.lang.Object` | `sizeGt(java.lang.String propertyName, int size)` Creates a Criterion that contrains a collection property to be greater than the given size
`java.lang.Object` | `sizeLe(java.lang.String propertyName, int size)` Creates a Criterion that contrains a collection property to be less than or equal to the given size
`java.lang.Object` | `sizeLt(java.lang.String propertyName, int size)` Creates a Criterion that contrains a collection property to be less than to the given size
`java.lang.Object` | `sizeNe(java.lang.String propertyName, int size)` Creates a Criterion that contrains a collection property to be not equal to the given size
`java.lang.Object` | `sqlRestriction(java.lang.String sqlRestriction)` Applies a sql restriction to the results to allow something like:
           def results = Person.withCriteria {
               sqlRestriction "char_length(first_name) <= 4"
           }
`void` | `sum(java.lang.String propertyName)` Adds a projection that allows the criteria to retrieve the sum of the results of a property
`void` | `sum(java.lang.String propertyName, java.lang.String alias)` Adds a projection that allows the criteria to retrieve the sum of the results of a property

Methods inherited from class groovy.lang.GroovyObjectSupport
groovy.lang.GroovyObjectSupport#setProperty(java.lang.String, java.lang.Object), groovy.lang.GroovyObjectSupport#getProperty(java.lang.String), groovy.lang.GroovyObjectSupport#getMetaClass(), groovy.lang.GroovyObjectSupport#setMetaClass(groovy.lang.MetaClass), groovy.lang.GroovyObjectSupport#invokeMethod(java.lang.String, java.lang.Object), groovy.lang.GroovyObjectSupport#wait(), groovy.lang.GroovyObjectSupport#wait(long), groovy.lang.GroovyObjectSupport#wait(long, int), 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()

Methods inherited from class java.lang.Object
java.lang.Object#wait(), java.lang.Object#wait(long), java.lang.Object#wait(long, int), java.lang.Object#equals(java.lang.Object), java.lang.Object#toString(), java.lang.Object#hashCode(), java.lang.Object#getClass(), java.lang.Object#notify(), java.lang.Object#notifyAll()

Field Detail

### AND

    public static final java.lang.String AND

### BETWEEN

    public static final java.lang.String BETWEEN

### EQUALS

    public static final java.lang.String EQUALS

### EQUALS_PROPERTY

    public static final java.lang.String EQUALS_PROPERTY

### GREATER_THAN

    public static final java.lang.String GREATER_THAN

### GREATER_THAN_OR_EQUAL

    public static final java.lang.String GREATER_THAN_OR_EQUAL

### GREATER_THAN_OR_EQUAL_PROPERTY

    public static final java.lang.String GREATER_THAN_OR_EQUAL_PROPERTY

### GREATER_THAN_PROPERTY

    public static final java.lang.String GREATER_THAN_PROPERTY

### ID_EQUALS

    public static final java.lang.String ID_EQUALS

### ILIKE

    public static final java.lang.String ILIKE

### IN

    public static final java.lang.String IN

### IS_EMPTY

    public static final java.lang.String IS_EMPTY

### IS_NOT_EMPTY

    public static final java.lang.String IS_NOT_EMPTY

### IS_NOT_NULL

    public static final java.lang.String IS_NOT_NULL

### IS_NULL

    public static final java.lang.String IS_NULL

### LESS_THAN

    public static final java.lang.String LESS_THAN

### LESS_THAN_OR_EQUAL

    public static final java.lang.String LESS_THAN_OR_EQUAL

### LESS_THAN_OR_EQUAL_PROPERTY

    public static final java.lang.String LESS_THAN_OR_EQUAL_PROPERTY

### LESS_THAN_PROPERTY

    public static final java.lang.String LESS_THAN_PROPERTY

### LIKE

    public static final java.lang.String LIKE

### NOT

    public static final java.lang.String NOT

### NOT_EQUAL

    public static final java.lang.String NOT_EQUAL

### NOT_EQUAL_PROPERTY

    public static final java.lang.String NOT_EQUAL_PROPERTY

### OR

    public static final java.lang.String OR

### ORDER_ASCENDING

    public static final java.lang.String ORDER_ASCENDING

### ORDER_DESCENDING

    public static final java.lang.String ORDER_DESCENDING

### RLIKE

    public static final java.lang.String RLIKE

### SIZE_EQUALS

    public static final java.lang.String SIZE_EQUALS

Constructor Detail

### HibernateCriteriaBuilder

    @SuppressWarnings({"unchecked","rawtypes"})
    public HibernateCriteriaBuilder(java.lang.Class targetClass, SessionFactory sessionFactory)

### HibernateCriteriaBuilder

    @SuppressWarnings("rawtypes")
    public HibernateCriteriaBuilder(java.lang.Class targetClass, SessionFactory sessionFactory, boolean uniqueResult)

Method Detail

### addProjectionToList

    protected void addProjectionToList(Projection propertyProjection, java.lang.String alias)

  Adds a projection to the projectList for the given alias
  Parameters:
    `propertyProjection` - The projection
    `alias` - The alias

### avg

    public void avg(java.lang.String propertyName)

  Adds a projection that allows the criteria to return the property average value
  Parameters:
    `propertyName` - The name of the property

### avg

    public void avg(java.lang.String propertyName, java.lang.String alias)

  Adds a projection that allows the criteria to return the property average value
  Parameters:
    `propertyName` - The name of the property
    `alias` - The alias to use

### between

    public java.lang.Object between(java.lang.String propertyName, java.lang.Object lo, java.lang.Object hi)

  Creates a "between" Criterion based on the property name and specified lo and hi values
  Parameters:
    `propertyName` - The property name
    `lo` - The low value
    `hi` - The high value
  Returns:
    A Criterion instance

### buildCriteria

    public Criteria buildCriteria(groovy.lang.Closure criteriaClosure)

### cache

    public void cache(boolean shouldCache)

  Whether to use the query cache
  Parameters:
    `shouldCache` - True if the query should be cached

### count

    public void count(java.lang.String propertyName)

  Adds a projection that allows the criteria to return the property count
  Parameters:
    `propertyName` - The name of the property

### count

    public void count(java.lang.String propertyName, java.lang.String alias)

  Adds a projection that allows the criteria to return the property count
  Parameters:
    `propertyName` - The name of the property
    `alias` - The alias to use

### countDistinct

    public void countDistinct(java.lang.String propertyName)

  Adds a projection that allows the criteria to return the distinct property count
  Parameters:
    `propertyName` - The name of the property

### countDistinct

    public void countDistinct(java.lang.String propertyName, java.lang.String alias)

  Adds a projection that allows the criteria to return the distinct property count
  Parameters:
    `propertyName` - The name of the property
    `alias` - The alias to use

### distinct

    public void distinct(java.lang.String propertyName)

  A projection that selects a distince property name
  Parameters:
    `propertyName` - The property name

### distinct

    public void distinct(java.lang.String propertyName, java.lang.String alias)

  A projection that selects a distince property name
  Parameters:
    `propertyName` - The property name
    `alias` - The alias to use

### distinct

    @SuppressWarnings("rawtypes")
    public void distinct(java.util.Collection propertyNames)

  A distinct projection that takes a list
  Parameters:
    `propertyNames` - The list of distince property names

### distinct

    @SuppressWarnings("rawtypes")
    public void distinct(java.util.Collection propertyNames, java.lang.String alias)

  A distinct projection that takes a list
  Parameters:
    `propertyNames` - The list of distince property names
    `alias` - The alias to use

### eq

    public java.lang.Object eq(java.lang.String propertyName, java.lang.Object propertyValue)

  Creates an "equals" Criterion based on the specified property name and value. Case-sensitive.
  Parameters:
    `propertyName` - The property name
    `propertyValue` - The property value
  Returns:
    A Criterion instance

### eq

    @SuppressWarnings("rawtypes")
    public java.lang.Object eq(java.util.Map params, java.lang.String propertyName, java.lang.Object propertyValue)

  Groovy moves the map to the first parameter if using the idiomatic form, e.g. `eq 'firstName', 'Fred', ignoreCase: true`.
  Parameters:
    `params` - optional map with customization parameters; currently only 'ignoreCase' is supported.
    propertyName
    propertyValue
  Returns:
    A Criterion instance

### eq

    @SuppressWarnings("rawtypes")
    public java.lang.Object eq(java.lang.String propertyName, java.lang.Object propertyValue, java.util.Map params)

  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.
  Parameters:
    `propertyName` - The property name
    `propertyValue` - The property value
    `params` - optional map with customization parameters; currently only 'ignoreCase' is supported.
  Returns:
    A Criterion instance

### eqProperty

    public java.lang.Object eqProperty(java.lang.String propertyName, java.lang.String otherPropertyName)

  Creates a Criterion that compares to class properties for equality
  Parameters:
    `propertyName` - The first property name
    `otherPropertyName` - The second property name
  Returns:
    A Criterion instance

### fetchMode

    public void fetchMode(java.lang.String associationPath, FetchMode fetchMode)

  Sets the fetch mode of an associated path
  Parameters:
    `associationPath` - The name of the associated path
    `fetchMode` - The fetch mode to set

### ge

    public java.lang.Object ge(java.lang.String propertyName, java.lang.Object propertyValue)

  Creates a "greater than or equal to" Criterion based on the specified property name and value
  Parameters:
    `propertyName` - The property name
    `propertyValue` - The property value
  Returns:
    A Criterion instance

### geProperty

    public java.lang.Object geProperty(java.lang.String propertyName, java.lang.String otherPropertyName)

  Creates a Criterion that tests if the first property is greater than or equal to the second property
  Parameters:
    `propertyName` - The first property name
    `otherPropertyName` - The second property name
  Returns:
    A Criterion instance

### getInstance

    public Criteria getInstance()

  Returns the criteria instance
  Returns:
    The criteria instance

### groupProperty

    public void groupProperty(java.lang.String propertyName)

  Adds a projection that allows the criteria's result to be grouped by a property
  Parameters:
    `propertyName` - The name of the property

### groupProperty

    public void groupProperty(java.lang.String propertyName, java.lang.String alias)

  Adds a projection that allows the criteria's result to be grouped by a property
  Parameters:
    `propertyName` - The name of the property
    `alias` - The alias to use

### gt

    public java.lang.Object gt(java.lang.String propertyName, java.lang.Object propertyValue)

  Creates a "greater than" Criterion based on the specified property name and value
  Parameters:
    `propertyName` - The property name
    `propertyValue` - The property value
  Returns:
    A Criterion instance

### gtProperty

    public java.lang.Object gtProperty(java.lang.String propertyName, java.lang.String otherPropertyName)

  Creates a Criterion that tests if the first property is greater than the second property
  Parameters:
    `propertyName` - The first property name
    `otherPropertyName` - The second property name
  Returns:
    A Criterion instance

### ilike

    public java.lang.Object ilike(java.lang.String propertyName, java.lang.Object propertyValue)

  Creates a Criterion with from the specified property name and "ilike" (a case sensitive version of "like") expression
  Parameters:
    `propertyName` - The property name
    `propertyValue` - The ilike value
  Returns:
    A Criterion instance

### in

    @SuppressWarnings("rawtypes")
    public java.lang.Object in(java.lang.String propertyName, java.util.Collection values)

  Applys a "in" contrain on the specified property
  Parameters:
    `propertyName` - The property name
    `values` - A collection of values
  Returns:
    A Criterion instance

### in

    public java.lang.Object in(java.lang.String propertyName, Object[] values)

  Applys a "in" contrain on the specified property
  Parameters:
    `propertyName` - The property name
    `values` - A collection of values
  Returns:
    A Criterion instance

### inList

    @SuppressWarnings("rawtypes")
    public java.lang.Object inList(java.lang.String propertyName, java.util.Collection values)

  Delegates to in as in is a Groovy keyword

### inList

    public java.lang.Object inList(java.lang.String propertyName, Object[] values)

  Delegates to in as in is a Groovy keyword

### invokeMethod

    @SuppressWarnings("rawtypes")
    @Override
    public java.lang.Object invokeMethod(java.lang.String name, java.lang.Object obj)

### join

    public void join(java.lang.String associationPath)

  Use a join query
  Parameters:
    `associationPath` - The path of the association

### le

    public java.lang.Object le(java.lang.String propertyName, java.lang.Object propertyValue)

  Creates a "less than or equal to" Criterion based on the specified property name and value
  Parameters:
    `propertyName` - The property name
    `propertyValue` - The property value
  Returns:
    A Criterion instance

### leProperty

    public java.lang.Object leProperty(java.lang.String propertyName, java.lang.String otherPropertyName)

  Creates a Criterion that tests if the first property is less than or equal to the second property
  Parameters:
    `propertyName` - The first property name
    `otherPropertyName` - The second property name
  Returns:
    A Criterion instance

### like

    public java.lang.Object like(java.lang.String propertyName, java.lang.Object propertyValue)

  Creates a Criterion with from the specified property name and "like" expression
  Parameters:
    `propertyName` - The property name
    `propertyValue` - The like value
  Returns:
    A Criterion instance

### lock

    public void lock(boolean shouldLock)

  Whether a pessimistic lock should be obtained.
  Parameters:
    `shouldLock` - True if it should

### lt

    public java.lang.Object lt(java.lang.String propertyName, java.lang.Object propertyValue)

  Creates a "less than" Criterion based on the specified property name and value
  Parameters:
    `propertyName` - The property name
    `propertyValue` - The property value
  Returns:
    A Criterion instance

### ltProperty

    public java.lang.Object ltProperty(java.lang.String propertyName, java.lang.String otherPropertyName)

  Creates a Criterion that tests if the first property is less than the second property
  Parameters:
    `propertyName` - The first property name
    `otherPropertyName` - The second property name
  Returns:
    A Criterion instance

### max

    public void max(java.lang.String propertyName)

  Adds a projection that allows the criteria to retrieve a maximum property value
  Parameters:
    `propertyName` - The name of the property

### max

    public void max(java.lang.String propertyName, java.lang.String alias)

  Adds a projection that allows the criteria to retrieve a maximum property value
  Parameters:
    `propertyName` - The name of the property
    `alias` - The alias to use

### min

    public void min(java.lang.String propertyName)

  Adds a projection that allows the criteria to retrieve a minimum property value
  Parameters:
    `propertyName` - The name of the property

### min

    public void min(java.lang.String propertyName, java.lang.String alias)

  Adds a projection that allows the criteria to retrieve a minimum property value
  Parameters:
    `alias` - The alias to use

### ne

    public java.lang.Object ne(java.lang.String propertyName, java.lang.Object propertyValue)

  Creates a "not equal" Criterion based on the specified property name and value
  Parameters:
    `propertyName` - The property name
    `propertyValue` - The property value
  Returns:
    The criterion object

### neProperty

    public java.lang.Object neProperty(java.lang.String propertyName, java.lang.String otherPropertyName)

  Creates a Criterion that compares to class properties for !equality
  Parameters:
    `propertyName` - The first property name
    `otherPropertyName` - The second property name
  Returns:
    A Criterion instance

### notEqual

    public java.lang.Object notEqual(java.lang.String propertyName, java.lang.Object propertyValue)

### order

    public java.lang.Object order(java.lang.String propertyName)

  Orders by the specified property name (defaults to ascending)
  Parameters:
    `propertyName` - The property name to order by
  Returns:
    A Order instance

### order

    public java.lang.Object order(java.lang.String propertyName, java.lang.String direction)

  Orders by the specified property name and direction
  Parameters:
    `propertyName` - The property name to order by
    `direction` - Either "asc" for ascending or "desc" for descending
  Returns:
    A Order instance

### property

    public void property(java.lang.String propertyName)

  A projection that selects a property name
  Parameters:
    `propertyName` - The name of the property

### property

    public void property(java.lang.String propertyName, java.lang.String alias)

  A projection that selects a property name
  Parameters:
    `propertyName` - The name of the property
    `alias` - The alias to use

### resultTransformer

    public void resultTransformer(ResultTransformer transformer)

  Sets the resultTransformer.
  Parameters:
    `resultTransformer` - The result transformer to use.

### rlike

    public java.lang.Object 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
  Parameters:
    `propertyName` - The property name
    `propertyValue` - The ilike value
  Returns:
    A Criterion instance

### rowCount

    public void rowCount()

  Adds a projection that allows the criteria to return the row count

### rowCount

    public void rowCount(java.lang.String alias)

  Adds a projection that allows the criteria to return the row count
  Parameters:
    `alias` - The alias to use

### select

    public void select(java.lang.String associationPath)

  Use a select query
  Parameters:
    `associationPath` - The path of the association

### setUniqueResult

    public void setUniqueResult(boolean uniqueResult)

  Set whether a unique result should be returned
  Parameters:
    `uniqueResult` - True if a unique result should be returned

### sizeEq

    public java.lang.Object sizeEq(java.lang.String propertyName, int size)

  Creates a Criterion that contrains a collection property by size
  Parameters:
    `propertyName` - The property name
    `size` - The size to constrain by
  Returns:
    A Criterion instance

### sizeGe

    public java.lang.Object sizeGe(java.lang.String propertyName, int size)

  Creates a Criterion that contrains a collection property to be greater than or equal to the given size
  Parameters:
    `propertyName` - The property name
    `size` - The size to constrain by
  Returns:
    A Criterion instance

### sizeGt

    public java.lang.Object sizeGt(java.lang.String propertyName, int size)

  Creates a Criterion that contrains a collection property to be greater than the given size
  Parameters:
    `propertyName` - The property name
    `size` - The size to constrain by
  Returns:
    A Criterion instance

### sizeLe

    public java.lang.Object sizeLe(java.lang.String propertyName, int size)

  Creates a Criterion that contrains a collection property to be less than or equal to the given size
  Parameters:
    `propertyName` - The property name
    `size` - The size to constrain by
  Returns:
    A Criterion instance

### sizeLt

    public java.lang.Object sizeLt(java.lang.String propertyName, int size)

  Creates a Criterion that contrains a collection property to be less than to the given size
  Parameters:
    `propertyName` - The property name
    `size` - The size to constrain by
  Returns:
    A Criterion instance

### sizeNe

    public java.lang.Object sizeNe(java.lang.String propertyName, int size)

  Creates a Criterion that contrains a collection property to be not equal to the given size
  Parameters:
    `propertyName` - The property name
    `size` - The size to constrain by
  Returns:
    A Criterion instance

### sqlRestriction

    public java.lang.Object sqlRestriction(java.lang.String sqlRestriction)

  Applies a sql restriction to the results to allow something like:

             def results = Person.withCriteria {
                 sqlRestriction "char_length(first_name) <= 4"
             }

  Parameters:
    `sqlRestriction` - the sql restriction
  Returns:
    a Criterion instance

### sum

    public void sum(java.lang.String propertyName)

  Adds a projection that allows the criteria to retrieve the sum of the results of a property
  Parameters:
    `propertyName` - The name of the property

### sum

    public void sum(java.lang.String propertyName, java.lang.String alias)

  Adds a projection that allows the criteria to retrieve the sum of the results of a property
  Parameters:
    `propertyName` - The name of the property
    `alias` - The alias to use

Groovy Documentation