public interface UnconstrainedDataManager
Delegates to DataStore
implementations, handles references between entities from different stores.
Perform some operations without security constraints.
Use this bean to perform some operations without security constraints.
Modifier and Type | Method and Description |
---|---|
<T> T |
create(java.lang.Class<T> entityClass)
Creates a new entity instance in memory.
|
long |
getCount(LoadContext<?> context)
Returns the number of entity instances for the given query passed in the
LoadContext . |
long |
getCount(ValueLoadContext context)
Returns the number of key-value pairs for the given query passed in the
ValueLoadContext . |
<T> T |
getReference(java.lang.Class<T> entityClass,
java.lang.Object id)
Returns an entity instance which can be used as a reference to an object which exists in the data store.
|
<T> T |
getReference(Id<T> entityId)
Returns an entity instance which can be used as a reference to an object which exists in the data store.
|
<E> FluentLoader<E> |
load(java.lang.Class<E> entityClass)
Entry point to the fluent API for loading entities.
|
<E> FluentLoader.ById<E> |
load(Id<E> entityId)
Entry point to the fluent API for loading entities.
|
<E> E |
load(LoadContext<E> context)
Loads a single entity instance.
|
<E> java.util.List<E> |
loadList(LoadContext<E> context)
Loads collection of entity instances.
|
<T> FluentValueLoader<T> |
loadValue(java.lang.String queryString,
java.lang.Class<T> valueClass)
Entry point to the fluent API for loading a single scalar value.
|
FluentValuesLoader |
loadValues(java.lang.String queryString)
Entry point to the fluent API for loading scalar values.
|
java.util.List<KeyValueEntity> |
loadValues(ValueLoadContext context)
Loads list of key-value pairs.
|
<E> void |
remove(Id<E> entityId)
Removes the entity instance from the data store by its id.
|
void |
remove(java.lang.Object... entity)
Removes the entities from their data stores.
|
<E> E |
save(E entity)
Saves the entity to its data store.
|
EntitySet |
save(java.lang.Object... entities)
Saves entities to their data stores.
|
EntitySet |
save(SaveContext context)
Saves a collection of entity instances to their data stores.
|
@Nullable <E> E load(LoadContext<E> context)
The depth of object graphs, starting from loaded instances, defined by FetchPlan
object passed in LoadContext
.
context
- LoadContext
object, defining what and how to load<E> java.util.List<E> loadList(LoadContext<E> context)
The depth of object graphs, starting from loaded instances, defined by FetchPlan
object passed in LoadContext
.
context
- LoadContext
object, defining what and how to loadlong getCount(LoadContext<?> context)
LoadContext
.context
- defines the queryEntitySet save(SaveContext context)
context
- SaveContext
object, containing entities and other informationEntitySet save(java.lang.Object... entities)
entities
- entities to save<E> E save(E entity)
entity
- entity instancevoid remove(java.lang.Object... entity)
entity
- entity instance<E> void remove(Id<E> entityId)
entityId
- entity idjava.util.List<KeyValueEntity> loadValues(ValueLoadContext context)
context
- defines a query for scalar values and a list of keys for returned KeyValueEntitylong getCount(ValueLoadContext context)
ValueLoadContext
.context
- defines the query<E> FluentLoader<E> load(java.lang.Class<E> entityClass)
Usage examples:
Customer customer = dataManager.load(Customer.class).id(someId).one(); List<Customer> customers = dataManager.load(Customer.class) .query("select c from sample$Customer c where c.name = :name") .parameter("name", "Smith") .fetchPlan("customer-fetch-plan") .list();
entityClass
- class of entity that needs to be loaded<E> FluentLoader.ById<E> load(Id<E> entityId)
Usage example:
Customer customer = dataManager.load(customerId).fetchPlan("with-grade").one();
entityId
- Id
of entity that needs to be loadedFluentValuesLoader loadValues(java.lang.String queryString)
Usage examples:
List<KeyValueEntity> customerDataList = dataManager.loadValues( "select c.name, c.status from sample$Customer c where c.name = :n") .properties("custName", "custStatus") .parameter("name", "Smith") .list(); KeyValueEntity customerData = dataManager.loadValues( "select c.name, count(c) from sample$Customer c group by c.name") .properties("custName", "custCount") .one();
queryString
- query string<T> FluentValueLoader<T> loadValue(java.lang.String queryString, java.lang.Class<T> valueClass)
Terminal methods of this API (list
, one
and optional
) return a single value
from the first column of the query result set. You should provide the expected type of this value in the second
parameter. Number types will be converted appropriately, so for example if the query returns Long and you
expected Integer, the returned value will be automatically converted from Long to Integer.
Usage examples:
Long customerCount = dataManager.loadValue( "select count(c) from sample$Customer c", Long.class).one();
queryString
- query stringvalueClass
- type of the returning value<T> T create(java.lang.Class<T> entityClass)
Metadata.create()
.entityClass
- entity class<T> T getReference(java.lang.Class<T> entityClass, java.lang.Object id)
For 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));
entityClass
- entity classid
- id of an existing object<T> T getReference(Id<T> entityId)
entityId
- id of an existing objectgetReference(Class, Object)