@CompileDynamic @Slf4j class GormStaticApi<D> extends AbstractGormApi<D> implements GormAllOperations<D>
Static methods for GORM
| Modifiers | Name | Description |
|---|---|---|
protected java.util.List<FinderMethod> |
finders |
|
protected MultiTenancySettings.MultiTenancyMode |
multiTenancyMode |
The multi-tenancy mode of the datastore this API was created for, resolved once at construction time. |
| 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, PlatformTransactionManager transactionManager) |
GormStaticApi(java.lang.Class<D> persistentClass, MappingContext mappingContext, java.util.List<FinderMethod> finders) |
GormStaticApi(java.lang.Class<D> persistentClass, MappingContext mappingContext, java.util.List<FinderMethod> finders, java.lang.String qualifier) |
GormStaticApi(java.lang.Class<D> persistentClass, MappingContext mappingContext, java.util.List<FinderMethod> finders, DatastoreResolver resolver, java.lang.String qualifier) |
GormStaticApi(java.lang.Class<D> persistentClass, MappingContext mappingContext, java.util.List<FinderMethod> finders, DatastoreResolver resolver, java.lang.String qualifier, GormRegistry registry) |
| Type Params | Return Type | Name and description |
|---|---|---|
|
D |
attach(D instance) |
|
protected java.io.Serializable |
convertIdentifier(Session session, java.io.Serializable id, boolean strict)Converts an identifier to the type of the identity as the lookup by key converts it: getAll and
load throw for an identifier that cannot be converted, and get finds no instance for it.
|
|
java.lang.Long |
count() |
|
D |
create() |
|
BuildableCriteria |
createCriteria() |
|
protected java.util.Map |
createQueryMapForExample(D example) |
|
protected GormStaticApi<D> |
createStaticApi(java.lang.Class<D> persistentClass, MappingContext mappingContext, java.util.List<FinderMethod> finders, DatastoreResolver resolver, java.lang.String qualifier) |
|
protected GrailsTransactionTemplate |
createTransactionTemplate() |
|
protected GrailsTransactionTemplate |
createTransactionTemplate(TransactionDefinition definition) |
|
protected java.io.Serializable |
currentTenantId()The current tenant id of the datastore this API is bound to. |
|
void |
delete(D instance) |
|
void |
delete(D instance, java.util.Map params) |
|
java.lang.Number |
deleteAll() |
|
java.lang.Number |
deleteAll(java.util.Map params) |
|
void |
deleteAll(java.lang.Iterable objectsToDelete) |
|
void |
deleteAll(java.lang.Object[] objectsToDelete) |
|
void |
deleteAll(java.util.Map params, java.lang.Iterable objectsToDelete) |
|
void |
deleteAll(java.util.Map params, java.lang.Object[] objectsToDelete) |
|
void |
discard(D instance) |
|
GormAllOperations<D> |
eachTenant(Closure callable) |
<T1> |
protected T1 |
executeQualified(java.lang.String qualifier, SessionCallback<T1> callback) |
|
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) |
|
D |
find(D example) |
|
D |
find(D example, java.util.Map args) |
|
D |
find(Closure callable) |
|
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() |
|
java.util.List<D> |
findAll(java.util.Map params) |
|
java.util.List<D> |
findAll(D example) |
|
java.util.List<D> |
findAll(D example, java.util.Map args) |
|
java.util.List<D> |
findAll(Closure callable) |
|
java.util.List<D> |
findAll(java.util.Map args, Closure callable) |
|
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) |
|
protected java.util.List<D> |
findAllByKeys(Session session, java.util.List<java.io.Serializable> keys)Finds the instances of the current tenant for the given keys. |
|
java.util.List<D> |
findAllWhere(java.util.Map queryMap) |
|
java.util.List<D> |
findAllWhere(java.util.Map queryMap, java.util.Map args) |
|
protected java.lang.Object |
findCachedInstance(Session session, java.io.Serializable key, java.io.Serializable tenantId)Returns the instance the session holds for the given key if it belongs to the given tenant. |
|
D |
findOrCreateWhere(java.util.Map queryMap) |
|
D |
findOrSaveWhere(java.util.Map queryMap) |
|
D |
findWhere(java.util.Map queryMap) |
|
D |
findWhere(java.util.Map queryMap, java.util.Map args) |
|
D |
first() |
|
D |
first(java.lang.String propertyName) |
|
D |
first(java.util.Map params) |
|
GormStaticApi<D> |
forQualifier(java.lang.String qualifier) |
|
D |
get(java.io.Serializable id) |
|
java.util.List<D> |
getAll(java.io.Serializable[] ids) |
|
java.util.List<D> |
getAll(java.lang.Iterable<java.io.Serializable> ids)Passes the identifiers on to getAll(Serializable...), so that a subclass that overrides it handles both. |
|
java.util.List<D> |
getAll() |
|
java.lang.Long |
getCount() |
|
java.util.List<FinderMethod> |
getGormDynamicFinders() |
|
PersistentEntity |
getGormPersistentEntity() |
|
PlatformTransactionManager |
getTransactionManager() |
|
protected TransactionTemplateFactory |
getTransactionTemplateFactory() |
|
java.io.Serializable |
ident(D instance) |
<T1> |
protected T1 |
inConnectionScope(Closure<T1> callable)Runs the callable with the entity's unqualified operations routed to this API's connection, when this API belongs to a named connection, as Book.moreBooks does. |
|
D |
insert(D instance) |
|
D |
insert(D instance, java.util.Map params) |
|
boolean |
instanceOf(D instance, java.lang.Class cls) |
|
boolean |
isAttached(D instance) |
|
protected boolean |
isRetrievedByQuery(Session session)Whether instances are retrieved by id through a query. |
|
D |
last() |
|
D |
last(java.lang.String propertyName) |
|
D |
last(java.util.Map params) |
|
java.util.List<D> |
list() |
|
java.util.List<D> |
list(java.util.Map params) |
|
D |
load(java.io.Serializable id) |
|
D |
lock(D instance) |
|
D |
lock(java.io.Serializable id) |
|
D |
lock(java.util.Map args, java.io.Serializable id) |
|
D |
merge(D instance) |
|
D |
merge(D instance, java.util.Map params) |
|
java.lang.Object |
methodMissing(java.lang.String name, java.lang.Object args) |
<T1> |
T1 |
mutex(D instance, Closure<T1> callable) |
|
java.lang.Object |
propertyMissing(java.lang.String name) |
|
void |
propertyMissing(java.lang.String name, java.lang.Object val) |
|
java.lang.Object |
propertyMissing(D instance, java.lang.String name) |
|
D |
proxy(java.io.Serializable id) |
|
protected D |
proxyByQuery(Session session, java.io.Serializable id)Returns the instance the session holds for the given id if it belongs to the current tenant, and otherwise a proxy that is initialized through a query by id, which the multi-tenant event listener restricts to the tenant that is current when the proxy is initialized. |
|
D |
read(java.io.Serializable id) |
|
D |
refresh(D instance) |
|
D |
refresh(D instance, java.util.Map args) |
|
protected java.util.List<D> |
retrieveAllByQuery(Session session, java.util.Collection<java.io.Serializable> ids, boolean strict)Retrieves the instances for the given identifiers through a query, which the multi-tenant event listener restricts to the current tenant. |
|
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.Iterable<?> objectsToSave) |
|
java.util.List<java.io.Serializable> |
saveAll(java.lang.Object[] objectsToSave) |
|
boolean |
supportsLockedRefresh() |
|
protected void |
unsupported(java.lang.Object method) |
|
DetachedCriteria<D> |
where(Closure callable) |
|
DetachedCriteria<D> |
whereAny(Closure callable) |
|
DetachedCriteria<D> |
whereLazy(Closure callable) |
<T1> |
T1 |
withCriteria(Closure<T1> callable) |
<T1> |
T1 |
withCriteria(java.util.Map builderArgs, Closure callable) |
<T1> |
T1 |
withDatastoreSession(Closure<T1> callable) |
<T1> |
T1 |
withId(java.io.Serializable tenantId, Closure<T1> callable) |
<T1> |
T1 |
withNewSession(Closure<T1> callable) |
<T1> |
T1 |
withNewSession(java.io.Serializable tenantId, Closure<T1> callable)Runs the callable in a new session for the tenant, with the tenant bound, so that the calls it makes on the class reach the tenant named here rather than the one that resolving would find. |
<T1> |
T1 |
withNewTransaction(Closure<T1> callable) |
<T1> |
T1 |
withNewTransaction(java.util.Map transactionProperties, Closure<T1> callable) |
<T1> |
T1 |
withSession(Closure<T1> callable) |
<T1> |
T1 |
withStatelessSession(Closure<T1> callable) |
|
GormAllOperations<D> |
withTenant(java.io.Serializable tenantId) |
<T1> |
T1 |
withTenant(java.io.Serializable tenantId, Closure<T1> callable) |
<T1> |
T1 |
withTenantTransaction(java.io.Serializable tenantId, Closure<T1> callable) |
<T1> |
T1 |
withTenantTransaction(java.io.Serializable tenantId, TransactionDefinition definition, Closure<T1> callable) |
<T1> |
T1 |
withTransaction(Closure<T1> callable) |
<T1> |
T1 |
withTransaction(java.util.Map transactionProperties, Closure<T1> callable) |
<T1> |
T1 |
withTransaction(TransactionDefinition definition, Closure<T1> callable) |
<T1> |
T1 |
withoutId(Closure<T1> callable) |
The multi-tenancy mode of the datastore this API was created for, resolved once at
construction time. Retained for source/binary compatibility with out-of-tree
GormStaticApi subclasses that reference this field directly.
Converts an identifier to the type of the identity as the lookup by key converts it: getAll and
load throw for an identifier that cannot be converted, and get finds no instance for it.
Protected rather than private because the session callbacks of this class call it.
session - The sessionid - The identifierstrict - Whether an identifier that cannot be converted throwsnull for an identifier that cannot be converted if not strictThe current tenant id of the datastore this API is bound to. Protected rather than private because the session callbacks of this class call it, and a call from a closure does not reach a private method when the API is a subclass instance.
Finds the instances of the current tenant for the given keys. An instance the session already holds is returned without a query, as the lookup by key returns it, and the others are queried without flushing the session. Protected rather than private because the session callbacks of this class call it.
session - The sessionkeys - The keys, already converted to the type of the identitynull for a key no instance was found forReturns the instance the session holds for the given key if it belongs to the given tenant. An instance that is waiting to be inserted and has no tenant id yet belongs to it as well, because the multi-tenant event listener assigns the current tenant when it inserts the instance. Protected rather than private because the session callbacks of this class call it.
session - The sessionkey - The key, already converted to the type of the identitytenantId - The current tenant idnull if the session holds none for the key or it belongs to another tenantPasses the identifiers on to getAll(Serializable...), so that a subclass that overrides it handles both.
Runs the callable with the entity's unqualified operations routed to this API's connection, when this API
belongs to a named connection, as Book.moreBooks does. Inside
Book.moreBooks.withTransaction { } a book.save() or a Book.list() then reaches
moreBooks, whose session and transaction are the ones open, rather than the default connection.
The default connection's API undoes an enclosing block for another connection in the same way. A qualifier
that names no connection, such as a DISCRIMINATOR tenant id, is left alone.
callable - What to run Whether instances are retrieved by id through a query. In MultiTenancyMode#DISCRIMINATOR#DISCRIMINATOR mode the
multi-tenant event listener restricts a query to the current tenant, but a lookup by key bypasses it, so the
instances of a multi-tenant entity are retrieved through a query instead. Inside
Tenants#withoutId(groovy.lang.Closure) a lookup by id is not restricted to a tenant and stays a lookup by
key. This is decided inside the session callback, as the listener decides it, so that a tenant that a qualifier
binds for the callback, as withTenant(tenantId).get(id) binds it, restricts the lookup inside
withoutId as well. Protected rather than private because the session callbacks of this class call it.
session - The sessionReturns the instance the session holds for the given id if it belongs to the current tenant, and otherwise a proxy that is initialized through a query by id, which the multi-tenant event listener restricts to the tenant that is current when the proxy is initialized. A proxy for an instance of another tenant then fails to initialize, as a proxy for an instance that does not exist does. A proxy initialized inside Tenants#withoutId(groovy.lang.Closure) looks the instance up by key, so it is not restricted to a tenant. Protected rather than private because the session callbacks of this class call it.
session - The sessionid - The identifierRetrieves the instances for the given identifiers through a query, which the multi-tenant event listener restricts to the current tenant. Protected rather than private because the session callbacks of this class call it.
session - The sessionids - The identifiersstrict - Whether an identifier that cannot be converted to the type of the identity throwsnull for an identifier no instance was found forRuns the callable in a new session for the tenant, with the tenant bound, so that the calls it makes on the class reach the tenant named here rather than the one that resolving would find.
tenantId - The tenantcallable - What to run