@groovy.transform.CompileStatic class GormStaticApi<D> extends AbstractGormApi<D> implements GormAllOperations<D>
Static methods of the GORM API.
D
- the entity/domain classModifiers | Name | Description |
---|---|---|
protected ConnectionSources |
connectionSources |
|
protected java.lang.String |
defaultQualifier |
|
protected java.util.List<FinderMethod> |
gormDynamicFinders |
|
protected MultiTenancySettings.MultiTenancyMode |
multiTenancyMode |
|
protected org.springframework.transaction.PlatformTransactionManager |
transactionManager |
Constructor and description |
---|
GormStaticApi(java.lang.Class<D> persistentClass, Datastore datastore, java.util.List<FinderMethod> finders) |
GormStaticApi(java.lang.Class<D> persistentClass, Datastore datastore, java.util.List<FinderMethod> finders, org.springframework.transaction.PlatformTransactionManager transactionManager) |
Type Params | Return Type | Name and description |
---|---|---|
|
D |
attach(D instance) |
|
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 |
delete(D instance) |
|
void |
delete(D instance, java.util.Map params) |
|
void |
deleteAll(java.lang.Object[] objectsToDelete) Deletes a list of objects in one go |
|
void |
deleteAll(java.util.Map params, java.lang.Object[] objectsToDelete) Deletes a list of objects in one go and flushes when param is set |
|
void |
deleteAll(java.lang.Iterable objectToDelete) Deletes a list of objects in one go |
|
void |
deleteAll(java.util.Map params, java.lang.Iterable objectToDelete) Deletes a list of objects in one go and flushes when param is set |
|
void |
discard(D instance) |
|
GormAllOperations<D> |
eachTenant(groovy.lang.Closure callable) |
|
java.util.List |
executeQuery(java.lang.CharSequence query) |
|
java.util.List |
executeQuery(java.lang.CharSequence query, java.util.Map args) |
|
java.util.List |
executeQuery(java.lang.CharSequence query, java.util.Map params, java.util.Map args) |
|
java.util.List |
executeQuery(java.lang.CharSequence query, java.util.Collection params) |
|
java.util.List |
executeQuery(java.lang.CharSequence query, java.lang.Object[] params) |
|
java.util.List |
executeQuery(java.lang.CharSequence query, java.util.Collection params, java.util.Map args) |
|
java.lang.Integer |
executeUpdate(java.lang.CharSequence query) |
|
java.lang.Integer |
executeUpdate(java.lang.CharSequence query, java.util.Map args) |
|
java.lang.Integer |
executeUpdate(java.lang.CharSequence query, java.util.Map params, java.util.Map args) |
|
java.lang.Integer |
executeUpdate(java.lang.CharSequence query, java.util.Collection params) |
|
java.lang.Integer |
executeUpdate(java.lang.CharSequence query, java.lang.Object[] params) |
|
java.lang.Integer |
executeUpdate(java.lang.CharSequence query, java.util.Collection params, java.util.Map args) |
|
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) |
|
D |
find(java.lang.CharSequence query, java.util.Map params) |
|
D |
find(java.lang.CharSequence query, java.util.Map params, java.util.Map args) |
|
D |
find(java.lang.CharSequence query, java.util.Collection params) |
|
D |
find(java.lang.CharSequence query, java.lang.Object[] params) |
|
D |
find(java.lang.CharSequence query, java.util.Collection params, java.util.Map args) |
|
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(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) |
|
java.util.List<D> |
findAll(java.lang.CharSequence query, java.util.Map params) |
|
java.util.List<D> |
findAll(java.lang.CharSequence query, java.util.Map params, java.util.Map args) |
|
java.util.List<D> |
findAll(java.lang.CharSequence query, java.util.Collection params) |
|
java.util.List<D> |
findAll(java.lang.CharSequence query, java.lang.Object[] params) |
|
java.util.List<D> |
findAll(java.lang.CharSequence query, java.util.Collection params, java.util.Map args) |
|
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 an 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()
|
|
java.lang.Integer |
getCount() Same as count() but allows property-style syntax (Foo.count) |
|
java.util.List<FinderMethod> |
getGormDynamicFinders() |
|
PersistentEntity |
getGormPersistentEntity()
|
|
java.io.Serializable |
ident(D instance) |
|
D |
insert(D instance) |
|
D |
insert(D instance, java.util.Map params) |
|
boolean |
instanceOf(D instance, java.lang.Class cls) |
|
boolean |
isAttached(D instance) |
|
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 an object from the datastore as a proxy. eg. |
|
D |
lock(java.io.Serializable id) Locks an instance for an update |
|
D |
lock(D instance) |
|
D |
merge(D d) |
|
D |
merge(D instance, java.util.Map params) |
|
java.lang.Object |
methodMissing(java.lang.String methodName, java.lang.Object args) Method missing handler that deals with the invocation of dynamic finders |
<T> |
T |
mutex(D instance, groovy.lang.Closure<T> callable) |
|
java.lang.Object |
propertyMissing(java.lang.String name) Property missing handler |
|
void |
propertyMissing(java.lang.String name, java.lang.Object value) Property missing handler |
|
java.lang.Object |
propertyMissing(D instance, java.lang.String name) Merges an instance with the current session |
|
D |
proxy(java.io.Serializable id) Retrieves an object from the datastore as a proxy. eg. |
|
D |
read(java.io.Serializable id) Retrieves an object from the datastore. eg. |
|
D |
refresh(D instance) |
|
D |
save(D instance) |
|
D |
save(D instance, boolean validate) |
|
D |
save(D instance, java.util.Map params) |
|
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 |
|
protected void |
unsupported(java.lang.Object method) |
|
DetachedCriteria<D> |
where(groovy.lang.Closure callable)
|
|
DetachedCriteria<D> |
whereAny(groovy.lang.Closure callable)
|
|
DetachedCriteria<D> |
whereLazy(groovy.lang.Closure callable)
|
|
java.lang.Object |
withCriteria(groovy.lang.Closure callable) Creates a criteria builder instance |
|
java.lang.Object |
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) |
|
GormAllOperations<D> |
withTenant(java.io.Serializable tenantId) |
<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 and flushes when param is set
objectsToDelete
- The objects to deleteDeletes a list of objects in one go
objectsToDelete
- Collection of objects to deleteDeletes a list of objects in one go and flushes when param is set
objectsToDelete
- Collection of objects to deleteChecks 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 argumentsUses 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()
Finds an object by example
example
- The exampleFinds an object by example using the given arguments for pagination
example
- The exampleargs
- The argumentsFinds 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 an 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 an object from the datastore as a proxy. eg. Book.load(1)
Locks an instance for an update
id
- The identifierMethod missing handler that deals with the invocation of dynamic finders
methodName
- The method nameargs
- The argumentsProperty missing handler
name
- The name of the propertyProperty missing handler
name
- The name of the propertyMerges an instance with the current session
d
- The object to mergeRetrieves an object from the datastore as a proxy. eg. Book.proxy(1)
Retrieves an 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
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.
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