public interface DataManager
In case of RdbmsStore
, works with non-managed (new or detached) entities, always starts and commits new
transactions.
When used on the client tier - always applies security restrictions. When used on the middleware - does not apply
security restrictions by default. If you want to apply security, get secure()
instance or set the
cuba.dataManagerChecksSecurityOnMiddleware
application property to use it by default.
Modifier and Type | Field and Description |
---|---|
static java.lang.String |
NAME |
Modifier and Type | Method and Description |
---|---|
java.util.Set<Entity> |
commit(CommitContext context)
Commits a collection of new or detached entity instances to the data store.
|
<E extends Entity> |
commit(E entity)
Commits the entity to the data store.
|
<E extends Entity> |
commit(E entity,
java.lang.String viewName)
Commits the entity to the data store.
|
<E extends Entity> |
commit(E entity,
View view)
Commits the entity to the data store.
|
long |
getCount(LoadContext<? extends Entity> context)
Returns the number of entity instances for the given query passed in the
LoadContext . |
<E extends Entity> |
load(LoadContext<E> context)
Loads a single entity instance.
|
<E extends Entity> |
loadList(LoadContext<E> context)
Loads collection of entity instances.
|
java.util.List<KeyValueEntity> |
loadValues(ValueLoadContext context)
Loads list of key-value pairs.
|
<E extends Entity> |
reload(E entity,
java.lang.String viewName)
Reloads the entity instance from data store with the view specified.
|
<E extends Entity> |
reload(E entity,
View view)
Reloads the entity instance from data store with the view specified.
|
<E extends Entity> |
reload(E entity,
View view,
MetaClass metaClass)
Reloads the entity instance from data store with the view specified.
|
<E extends Entity> |
reload(E entity,
View view,
MetaClass metaClass,
boolean loadDynamicAttributes)
Reloads the entity instance from data store with the view specified.
|
void |
remove(Entity entity)
Removes the entity instance from the data store.
|
DataManager |
secure()
Returns the DataManager implementation that is guaranteed to apply security restrictions.
|
static final java.lang.String NAME
@Nullable <E extends Entity> E load(LoadContext<E> context)
The depth of object graphs, starting from loaded instances, defined by View
object passed in LoadContext
.
context
- LoadContext
object, defining what and how to load<E extends Entity> java.util.List<E> loadList(LoadContext<E> context)
The depth of object graphs, starting from loaded instances, defined by View
object passed in LoadContext
.
context
- LoadContext
object, defining what and how to loadlong getCount(LoadContext<? extends Entity> context)
LoadContext
.context
- defines the query<E extends Entity> E reload(E entity, java.lang.String viewName)
entity
- reloading instanceviewName
- view nameEntityAccessException
- if the entity cannot be reloaded because it was deleted or access restrictions has been changed<E extends Entity> E reload(E entity, View view)
entity
- reloading instanceview
- view objectEntityAccessException
- if the entity cannot be reloaded because it was deleted or access restrictions has been changed<E extends Entity> E reload(E entity, View view, @Nullable MetaClass metaClass)
entity
- reloading instanceview
- view objectmetaClass
- desired MetaClass, if null - original entity's metaclass is usedEntityAccessException
- if the entity cannot be reloaded because it was deleted or access restrictions has been changed<E extends Entity> E reload(E entity, View view, @Nullable MetaClass metaClass, boolean loadDynamicAttributes)
entity
- reloading instanceview
- view objectmetaClass
- desired MetaClass, if null - original entity's metaclass is usedloadDynamicAttributes
- whether to load dynamic attributes for the entityEntityAccessException
- if the entity cannot be reloaded because it was deleted or access restrictions has been changedjava.util.Set<Entity> commit(CommitContext context)
context
- CommitContext
object, containing committing entities and other information<E extends Entity> E commit(E entity, @Nullable View view)
entity
- entity instanceview
- view object, affects the returned committed instance<E extends Entity> E commit(E entity, @Nullable java.lang.String viewName)
entity
- entity instanceviewName
- view name, affects the returned committed instance<E extends Entity> E commit(E entity)
entity
- entity instancevoid remove(Entity entity)
entity
- entity instancejava.util.List<KeyValueEntity> loadValues(ValueLoadContext context)
context
- defines a query for scalar values and a list of keys for returned KeyValueEntityDataManager secure()
By default, DataManager does not apply security when used on the middleware. Use this method if you want to run the same code both on the client and middle tier. For example:
AppBeans.get(DataManager.class).secure().load(context);