Interface for the default static methods in GORM
Type Params | Return Type | Name and description |
---|---|---|
|
java.lang.Integer |
count() Counts the number of persisted entities |
|
D |
create() Creates an instance of this class |
|
BuildableCriteria |
createCriteria() Creates a criteria builder instance |
|
void |
deleteAll(java.lang.Object... objectsToDelete) Deletes a list of objects in one go |
|
void |
deleteAll(java.lang.Iterable objectToDelete) Deletes a list of objects in one go |
|
GormAllOperations<D> |
eachTenant(groovy.lang.Closure callable) Execute the closure for each tenant |
|
java.util.List |
executeQuery(java.lang.CharSequence query) Executes a query for the given String |
|
java.util.List |
executeQuery(java.lang.CharSequence query, java.util.Map args) Executes a query for the given String |
|
java.util.List |
executeQuery(java.lang.CharSequence query, java.util.Map params, java.util.Map args) Executes a query for the given String |
|
java.util.List |
executeQuery(java.lang.CharSequence query, java.util.Collection params) Executes a query for the given String |
|
java.util.List |
executeQuery(java.lang.CharSequence query, java.lang.Object... params) Executes a query for the given String |
|
java.util.List |
executeQuery(java.lang.CharSequence query, java.util.Collection params, java.util.Map args) Executes a query for the given String |
|
java.lang.Integer |
executeUpdate(java.lang.CharSequence query) Executes an update for the given String |
|
java.lang.Integer |
executeUpdate(java.lang.CharSequence query, java.util.Map args) Executes an update for the given String |
|
java.lang.Integer |
executeUpdate(java.lang.CharSequence query, java.util.Map params, java.util.Map args) Executes an update for the given String |
|
java.lang.Integer |
executeUpdate(java.lang.CharSequence query, java.util.Collection params) Executes an update for the given String |
|
java.lang.Integer |
executeUpdate(java.lang.CharSequence query, java.lang.Object... params) Executes an update for the given String |
|
java.lang.Integer |
executeUpdate(java.lang.CharSequence query, java.util.Collection params, java.util.Map args) Executes an update for the given String |
|
boolean |
exists(java.io.Serializable id) Checks whether an entity exists |
|
D |
find(groovy.lang.Closure callable) Uses detached criteria to build a query and then execute it returning a list |
|
D |
find(D example) Finds an object by example |
|
D |
find(D example, java.util.Map args) Finds an object by example using the given arguments for pagination |
|
D |
find(java.lang.CharSequence query) Finds an object for the given string-based query |
|
D |
find(java.lang.CharSequence query, java.util.Map params) Finds an object for the given string-based query and named parameters |
|
D |
find(java.lang.CharSequence query, java.util.Map params, java.util.Map args) Finds an object for the given string-based query, named parameters and arguments |
|
D |
find(java.lang.CharSequence query, java.util.Collection params) Finds an object for the given string-based query and positional parameters |
|
D |
find(java.lang.CharSequence query, java.lang.Object[] params) Finds an object for the given string-based query and positional parameters |
|
D |
find(java.lang.CharSequence query, java.util.Collection params, java.util.Map args) Finds an object for the given string-based query, positional parameters and arguments |
|
java.util.List<D> |
findAll(groovy.lang.Closure callable) Uses detached criteria to build a query and then execute it returning a list |
|
java.util.List<D> |
findAll(java.util.Map args, groovy.lang.Closure callable) Uses detached criteria to build a query and then execute it returning a list |
|
java.util.List<D> |
findAll(java.util.Map params) The same as list() |
|
java.util.List<D> |
findAll() The same as list() |
|
java.util.List<D> |
findAll(D example) Finds an object by example |
|
java.util.List<D> |
findAll(D example, java.util.Map args) Finds an object by example using the given arguments for pagination |
|
java.util.List<D> |
findAll(java.lang.CharSequence query) Finds all objects for the given string-based query |
|
java.util.List<D> |
findAll(java.lang.CharSequence query, java.util.Map params) Finds all objects for the given string-based query and named parameters |
|
java.util.List<D> |
findAll(java.lang.CharSequence query, java.util.Map params, java.util.Map args) Finds all objects for the given string-based query, named parameters and arguments |
|
java.util.List<D> |
findAll(java.lang.CharSequence query, java.util.Collection params) Finds all objects for the given string-based query and positional parameters |
|
java.util.List<D> |
findAll(java.lang.CharSequence query, java.lang.Object[] params) Finds all objects for the given string-based query and positional parameters |
|
java.util.List<D> |
findAll(java.lang.CharSequence query, java.util.Collection params, java.util.Map args) Finds all objects for the given string-based query, positional parameters and arguments |
|
java.util.List<D> |
findAllWhere(java.util.Map queryMap) Finds all results matching all of the given conditions. |
|
java.util.List<D> |
findAllWhere(java.util.Map queryMap, java.util.Map args) Finds all results matching all of the given conditions. |
|
D |
findOrCreateWhere(java.util.Map queryMap) Finds a single result matching all of the given conditions. |
|
D |
findOrSaveWhere(java.util.Map queryMap) Finds a single result matching all of the given conditions. |
|
D |
findWhere(java.util.Map queryMap) Finds a single result matching all of the given conditions. |
|
D |
findWhere(java.util.Map queryMap, java.util.Map args) Finds a single result matching all of the given conditions. |
|
D |
first() Finds the first object using the natural sort order |
|
D |
first(java.lang.String propertyName) Finds the first object sorted by propertyName |
|
D |
first(java.util.Map queryParams) Finds the first object. |
|
D |
get(java.io.Serializable id) Retrieves and object from the datastore. eg. |
|
java.util.List<D> |
getAll(java.lang.Iterable<java.io.Serializable> ids) Retrieve all the objects for the given identifiers |
|
java.util.List<D> |
getAll(java.io.Serializable... ids) Retrieve all the objects for the given identifiers |
|
java.util.List<D> |
getAll() @return Synonym for list() |
|
java.lang.Integer |
getCount() Same as count() but allows property-style syntax (Foo.count) |
|
java.util.List<FinderMethod> |
getGormDynamicFinders() @return The GORM dynamic finders |
|
PersistentEntity |
getGormPersistentEntity() @return The PersistentEntity for this class |
|
D |
last() Finds the last object using the natural sort order |
|
D |
last(java.lang.String propertyName) Finds the last object sorted by propertyName |
|
D |
last(java.util.Map queryParams) Finds the last object. |
|
java.util.List<D> |
list(java.util.Map params) Lists objects in the datastore. eg. |
|
java.util.List<D> |
list() List all entities |
|
D |
load(java.io.Serializable id) Retrieves and object from the datastore as a proxy. eg. |
|
D |
lock(java.io.Serializable id) Locks an instance for an update |
|
D |
merge(D d) Merges an instance with the current session |
|
java.lang.Object |
methodMissing(java.lang.String methodName, java.lang.Object arg) Handles static method missing for dynamic finders |
|
java.lang.Object |
propertyMissing(java.lang.String property) Handles property missing, does nothing by default, sub traits to override |
|
void |
propertyMissing(java.lang.String property, java.lang.Object value) Handles property missing, does nothing by default, sub traits to override |
|
D |
proxy(java.io.Serializable id) Retrieves and object from the datastore as a proxy. eg. |
|
D |
read(java.io.Serializable id) Retrieves and object from the datastore. eg. |
|
java.util.List<java.io.Serializable> |
saveAll(java.lang.Object... objectsToSave) Saves a list of objects in one go |
|
java.util.List<java.io.Serializable> |
saveAll(java.lang.Iterable<?> objectsToSave) Saves a list of objects in one go |
|
DetachedCriteria<D> |
where(groovy.lang.Closure callable) @param callable Callable closure containing detached criteria definition |
|
DetachedCriteria<D> |
whereAny(groovy.lang.Closure callable) @param callable Callable closure containing detached criteria definition |
|
DetachedCriteria<D> |
whereLazy(groovy.lang.Closure callable) @param callable Callable closure containing detached criteria definition |
<T> |
T |
withCriteria(groovy.lang.Closure<T> callable) Creates a criteria builder instance |
<T> |
T |
withCriteria(java.util.Map builderArgs, groovy.lang.Closure callable) Creates a criteria builder instance |
<T> |
T |
withDatastoreSession(groovy.lang.Closure<T> callable) Same as withSession, but present for the case where withSession is overridden to use the Hibernate session |
<T> |
T |
withNewSession(groovy.lang.Closure<T> callable) Creates and binds a new session for the scope of the given closure |
<T> |
T |
withNewTransaction(groovy.lang.Closure<T> callable) Executes the closure within the context of a new transaction |
<T> |
T |
withNewTransaction(java.util.Map transactionProperties, groovy.lang.Closure<T> callable) Executes the closure within the context of a new transaction which is configured with the properties contained in transactionProperties. |
<T> |
T |
withSession(groovy.lang.Closure<T> callable) Execute a closure whose first argument is a reference to the current session. |
<T> |
T |
withStatelessSession(groovy.lang.Closure<T> callable) Creates and binds a new session for the scope of the given closure |
<T> |
T |
withTenant(java.io.Serializable tenantId, groovy.lang.Closure<T> callable) Execute the closure with the given tenantId |
|
GormAllOperations<D> |
withTenant(java.io.Serializable tenantId) Return the GormAllOperations for the given tenant id |
<T> |
T |
withTransaction(groovy.lang.Closure<T> callable) Executes the closure within the context of a transaction, creating one if none is present or joining an existing transaction if one is already present. |
<T> |
T |
withTransaction(java.util.Map transactionProperties, groovy.lang.Closure<T> callable) Executes the closure within the context of a transaction which is configured with the properties contained in transactionProperties. |
<T> |
T |
withTransaction(org.springframework.transaction.TransactionDefinition definition, groovy.lang.Closure<T> callable) Executes the closure within the context of a transaction for the given org.springframework.transaction.TransactionDefinition |
Counts the number of persisted entities
Creates an instance of this class
Creates a criteria builder instance
Deletes a list of objects in one go
objectsToDelete
- The objects to deleteDeletes a list of objects in one go
objectsToDelete
- Collection of objects to deleteExecute the closure for each tenant
callable
- The closureExecutes a query for the given String
query
- The query represented by the given stringExecutes a query for the given String
query
- The query represented by the given stringargs
- The arguments to the queryExecutes a query for the given String
query
- The query represented by the given stringparams
- The named parameters to the queryargs
- The arguments to the queryExecutes a query for the given String
query
- The query represented by the given stringparams
- The positional parameters to the queryExecutes a query for the given String
query
- The query represented by the given stringparams
- The positional parameters to the queryExecutes a query for the given String
query
- The query represented by the given stringparams
- The positional parameters to the queryargs
- The arguments to the queryExecutes an update for the given String
query
- The query represented by the given stringExecutes an update for the given String
query
- The query represented by the given stringparams
- The parameters to the queryExecutes an update for the given String
query
- The query represented by the given stringparams
- The parameters to the queryargs
- The arguments to the queryExecutes an update for the given String
query
- The query represented by the given stringparams
- The positional parameters to the queryExecutes an update for the given String
query
- The query represented by the given stringparams
- The positional parameters to the queryExecutes an update for the given String
query
- The query represented by the given stringparams
- The positional parameters to the queryargs
- The arguments to the queryChecks whether an entity exists
Uses detached criteria to build a query and then execute it returning a list
callable
- The callableFinds an object by example
example
- The exampleFinds an object by example using the given arguments for pagination
example
- The exampleargs
- The argumentsFinds an object for the given string-based query
query
- The queryFinds an object for the given string-based query and named parameters
query
- The queryparams
- The parametersFinds an object for the given string-based query, named parameters and arguments
query
- The queryparams
- The parametersFinds an object for the given string-based query and positional parameters
query
- The queryparams
- The parametersFinds an object for the given string-based query and positional parameters
query
- The queryparams
- The parametersFinds an object for the given string-based query, positional parameters and arguments
query
- The queryparams
- The parametersUses detached criteria to build a query and then execute it returning a list
callable
- The callableUses detached criteria to build a query and then execute it returning a list
args
- pagination parameterscallable
- The callableThe same as list()
The same as list()
Finds an object by example
example
- The exampleFinds an object by example using the given arguments for pagination
example
- The exampleargs
- The argumentsFinds all objects for the given string-based query
query
- The queryFinds all objects for the given string-based query and named parameters
query
- The queryparams
- The parametersFinds all objects for the given string-based query, named parameters and arguments
query
- The queryparams
- The parametersFinds all objects for the given string-based query and positional parameters
query
- The queryparams
- The parametersFinds all objects for the given string-based query and positional parameters
query
- The queryparams
- The parametersFinds all objects for the given string-based query, positional parameters and arguments
query
- The queryparams
- The parametersFinds all results matching all of the given conditions. Eg. Book.findAllWhere(author:"Stephen King", title:"The Stand")
queryMap
- The map of conditionsFinds all results matching all of the given conditions. Eg. Book.findAllWhere(author:"Stephen King", title:"The Stand")
queryMap
- The map of conditionsargs
- The Query argumentsFinds a single result matching all of the given conditions. Eg. Book.findWhere(author:"Stephen King", title:"The Stand"). If a matching persistent entity is not found a new entity is created and returned.
queryMap
- The map of conditionsFinds a single result matching all of the given conditions. Eg. Book.findWhere(author:"Stephen King", title:"The Stand"). If a matching persistent entity is not found a new entity is created, saved and returned.
queryMap
- The map of conditionsFinds a single result matching all of the given conditions. Eg. Book.findWhere(author:"Stephen King", title:"The Stand")
queryMap
- The map of conditionsFinds a single result matching all of the given conditions. Eg. Book.findWhere(author:"Stephen King", title:"The Stand")
queryMap
- The map of conditionsargs
- The Query argumentsFinds the first object using the natural sort order
Finds the first object sorted by propertyName
propertyName
- the name of the property to sort byFinds the first object. If queryParams includes 'sort', that will dictate the sort order, otherwise natural sort order will be used. queryParams may include any of the same parameters that might be passed to the list(Map) method. This method will ignore 'order' and 'max' as those are always 'asc' and 1, respectively.
Retrieves and object from the datastore. eg. Book.get(1)
Retrieve all the objects for the given identifiers
ids
- The identifiers to operate againstRetrieve all the objects for the given identifiers
ids
- The identifiers to operate against
Same as count() but allows property-style syntax (Foo.count)
Finds the last object using the natural sort order
Finds the last object sorted by propertyName
propertyName
- the name of the property to sort byFinds the last object. If queryParams includes 'sort', that will dictate the sort order, otherwise natural sort order will be used. queryParams may include any of the same parameters that might be passed to the list(Map) method. This method will ignore 'order' and 'max' as those are always 'asc' and 1, respectively.
Lists objects in the datastore. eg. Book.list(max:10)
params
- Any parameters such as offset, max etc.List all entities
Retrieves and object from the datastore as a proxy. eg. Book.load(1)
Locks an instance for an update
id
- The identifierMerges an instance with the current session
d
- The object to mergeHandles static method missing for dynamic finders
methodName
- The name of the methodarg
- the argument to the methodHandles property missing, does nothing by default, sub traits to override
property
- The propertyHandles property missing, does nothing by default, sub traits to override
property
- The propertyvalue
- The value of the propertyRetrieves and object from the datastore as a proxy. eg. Book.proxy(1)
Retrieves and object from the datastore. eg. Book.read(1) Since the datastore abstraction doesn't support dirty checking yet this just delegates to get(Serializable)
Saves a list of objects in one go
objectsToSave
- The objects to saveSaves a list of objects in one go
objectToSave
- Collection of objects to save
callable
- Callable closure containing detached criteria definition
callable
- Callable closure containing detached criteria definition
callable
- Callable closure containing detached criteria definitionCreates a criteria builder instance
Creates a criteria builder instance
Same as withSession, but present for the case where withSession is overridden to use the Hibernate session
callable
- the closureCreates and binds a new session for the scope of the given closure
Executes the closure within the context of a new transaction
callable
- The closure to callExecutes the closure within the context of a new transaction which is configured with the properties contained in transactionProperties. transactionProperties may contain any properties supported by org.springframework.transaction.support.DefaultTransactionDefinition. Note that if transactionProperties includes entries for propagationBehavior or propagationName, those values will be ignored. This method always sets the propagation level to TransactionDefinition.REQUIRES_NEW.
SomeEntity.withNewTransaction([isolationLevel: TransactionDefinition.ISOLATION_REPEATABLE_READ]) { // ... }
transactionProperties
- properties to configure the transaction propertiescallable
- The closure to callExecute a closure whose first argument is a reference to the current session.
callable
- the closureCreates and binds a new session for the scope of the given closure
Execute the closure with the given tenantId
tenantId
- The tenant idcallable
- The closureReturn the GormAllOperations for the given tenant id
tenantId
- The tenant idExecutes the closure within the context of a transaction, creating one if none is present or joining an existing transaction if one is already present.
callable
- The closure to callExecutes the closure within the context of a transaction which is configured with the properties contained in transactionProperties. transactionProperties may contain any properties supported by org.springframework.transaction.support.DefaultTransactionDefinition.
SomeEntity.withTransaction([propagationBehavior: TransactionDefinition.PROPAGATION_REQUIRES_NEW, isolationLevel: TransactionDefinition.ISOLATION_REPEATABLE_READ]) { // ... }
transactionProperties
- properties to configure the transaction propertiescallable
- The closure to callExecutes the closure within the context of a transaction for the given org.springframework.transaction.TransactionDefinition
callable
- The closure to call