@Component(value="cuba_DataManager") public class DataManagerClientImpl extends java.lang.Object implements DataManager
NAME| Constructor and Description |
|---|
DataManagerClientImpl() |
| Modifier and Type | Method and Description |
|---|---|
EntitySet |
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.
|
EntitySet |
commit(Entity... entities)
Commits new or detached entity instances 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.
|
<T> T |
create(java.lang.Class<T> entityClass)
Creates a new entity instance in memory.
|
long |
getCount(LoadContext<? extends Entity> context)
Returns the number of entity instances for the given query passed in the
LoadContext. |
<T extends BaseGenericIdEntity<K>,K> |
getReference(java.lang.Class<T> entityClass,
K id)
Returns an entity instance which can be used as a reference to an object which exists in the database.
|
<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()
By default, DataManager does not apply security restrictions on entity operations and attributes, only row-level
constraints take effect.
|
equals, getClass, hashCode, notify, notifyAll, toString, wait, wait, waitload, load, loadValue, loadValues@Nullable public <E extends Entity> E load(LoadContext<E> context)
DataManagerThe depth of object graphs, starting from loaded instances, defined by View
object passed in LoadContext.
load in interface DataManagercontext - LoadContext object, defining what and how to load@Nonnull public <E extends Entity> java.util.List<E> loadList(LoadContext<E> context)
DataManagerThe depth of object graphs, starting from loaded instances, defined by View
object passed in LoadContext.
loadList in interface DataManagercontext - LoadContext object, defining what and how to loadpublic long getCount(LoadContext<? extends Entity> context)
DataManagerLoadContext.getCount in interface DataManagercontext - defines the querypublic <E extends Entity> E reload(E entity, java.lang.String viewName)
DataManagerreload in interface DataManagerentity - reloading instanceviewName - view namepublic <E extends Entity> E reload(E entity, View view)
DataManagerreload in interface DataManagerentity - reloading instanceview - view objectpublic <E extends Entity> E reload(E entity, View view, @Nullable MetaClass metaClass)
DataManagerreload in interface DataManagerentity - reloading instanceview - view objectmetaClass - desired MetaClass, if null - original entity's metaclass is usedpublic <E extends Entity> E reload(E entity, View view, @Nullable MetaClass metaClass, boolean loadDynamicAttributes)
DataManagerreload in interface DataManagerentity - reloading instanceview - view objectmetaClass - desired MetaClass, if null - original entity's metaclass is usedloadDynamicAttributes - whether to load dynamic attributes for the entitypublic EntitySet commit(CommitContext context)
DataManagercommit in interface DataManagercontext - CommitContext object, containing committing entities and other informationpublic <E extends Entity> E commit(E entity, @Nullable View view)
DataManagercommit in interface DataManagerentity - entity instanceview - view object, affects the returned committed instancepublic <E extends Entity> E commit(E entity, @Nullable java.lang.String viewName)
DataManagercommit in interface DataManagerentity - entity instanceviewName - view name, affects the returned committed instancepublic <E extends Entity> E commit(E entity)
DataManagercommit in interface DataManagerentity - entity instancepublic EntitySet commit(Entity... entities)
DataManagercommit in interface DataManagerentities - entities to commitpublic void remove(Entity entity)
DataManagerremove in interface DataManagerentity - entity instancepublic java.util.List<KeyValueEntity> loadValues(ValueLoadContext context)
DataManagerloadValues in interface DataManagercontext - defines a query for scalar values and a list of keys for returned KeyValueEntitypublic DataManager secure()
DataManager
This method returns the DataManager implementation that applies security restrictions on entity operations.
Attribute permissions will be enforced only if you additionally set the cuba.entityAttributePermissionChecking
application property to true.
Usage example:
AppBeans.get(DataManager.class).secure().load(context);
secure in interface DataManagerpublic <T> T create(java.lang.Class<T> entityClass)
DataManagerMetadata.create().create in interface DataManagerentityClass - entity classpublic <T extends BaseGenericIdEntity<K>,K> T getReference(java.lang.Class<T> entityClass, K id)
DataManagerFor example, if you are creating a User, you have to set a Group the user belongs to. If you know the group id, you could load it from the database and set to the user. This method saves you from unneeded database round trip:
user.setGroup(dataManager.getReference(Group.class, groupId)); dataManager.commit(user);A reference can also be used to delete an existing object by id:
dataManager.remove(dataManager.getReference(Customer.class, customerId));
getReference in interface DataManagerentityClass - entity classid - id of an existing object