T - entity base type. See EntityStore.@ParametersAreNonnullByDefault public class CompletableEntityStore<T> extends Object implements CompletionStageEntityStore<T>
CompletionStageEntityStore where all operations are passed through a
BlockingEntityStore instance. All operations are supplied via the given Executor.| Constructor and Description |
|---|
CompletableEntityStore(BlockingEntityStore<T> delegate) |
CompletableEntityStore(BlockingEntityStore<T> delegate,
Executor executor) |
| Modifier and Type | Method and Description |
|---|---|
void |
close()
Close the entity store.
|
<E extends T> |
count(Class<E> type)
Initiates a query to count the number of entities of a given type.
|
Selection<? extends Scalar<Integer>> |
count(QueryAttribute<?,?>... attributes)
Initiates a query to count a given selection.
|
Deletion<? extends Scalar<Integer>> |
delete()
Initiates a delete query against this data store.
|
<E extends T> |
delete(Class<E> type)
Initiates an delete query for a type.
|
<E extends T> |
delete(E entity)
Deletes the given entity from the store.
|
<E extends T> |
delete(Iterable<E> entities)
Deletes multiple entities.
|
<E extends T,K> |
findByKey(Class<E> type,
K key)
Find an entity by the given key.
|
<E extends T> |
insert(Class<E> type)
Initiates an insert operation for a type.
|
<E extends T> |
insert(E entity)
Inserts the given entity.
|
<K,E extends T> |
insert(E entity,
Class<K> keyClass)
Inserts the given entity returning the generated key after the entity is inserted.
|
<E extends T> |
insert(Iterable<E> entities)
Insert a collection of entities.
|
<K,E extends T> |
insert(Iterable<E> entities,
Class<K> keyClass)
Insert a collection of entities returning the generated keys for the inserted entities in
the order they were inserted.
|
<E extends T> |
raw(Class<E> type,
String query,
Object... parameters)
Executes a raw query against the data store mapping on to a specific entity type.
|
Result<Tuple> |
raw(String query,
Object... parameters)
Executes a raw query against the data store.
|
<E extends T> |
refresh(E entity)
Refresh the given entity.
|
<E extends T> |
refresh(E entity,
Attribute<?,?>... attributes)
Refresh the given entity on specific attributes.
|
<E extends T> |
refresh(Iterable<E> entities,
Attribute<?,?>... attributes)
Refresh the given entities on specific attributes.
|
<E extends T> |
refreshAll(E entity)
Refresh the given entity on all of its attributes including relational ones.
|
<E extends T> |
select(Class<E> type,
QueryAttribute<?,?>... attributes)
Initiates a query against a set of expression values return a specific entity type in a
Result. |
<E extends T> |
select(Class<E> type,
Set<? extends QueryAttribute<E,?>> attributes)
Initiates a query against a set of expression values return a specific entity type in a
Result. |
Selection<? extends Result<Tuple>> |
select(Expression<?>... expressions)
Initiates a query against a set of expression values.
|
Selection<? extends Result<Tuple>> |
select(Set<? extends Expression<?>> expressions)
Initiates a query against a set of expression values.
|
BlockingEntityStore<T> |
toBlocking() |
Update<? extends Scalar<Integer>> |
update()
Initiates an update query against this data store.
|
<E extends T> |
update(Class<E> type)
Initiates an update query for a type.
|
<E extends T> |
update(E entity)
Update the given entity.
|
<E extends T> |
update(E entity,
Attribute<?,?>... attributes)
Update specific attributes of entity regardless of any modification state.
|
<E extends T> |
update(Iterable<E> entities)
Updates a collection of entities.
|
<E extends T> |
upsert(E entity)
Upserts (insert or update) the given entity.
|
<E extends T> |
upsert(Iterable<E> entities)
Upserts (inserts or updates) a collection of entities.
|
public CompletableEntityStore(BlockingEntityStore<T> delegate)
public CompletableEntityStore(BlockingEntityStore<T> delegate, Executor executor)
public <E extends T> CompletableFuture<E> insert(E entity)
EntityStorePersistenceException may be thrown.insert in interface CompletionStageEntityStore<T>insert in interface EntityStore<T,CompletionStage<?>>E - entity typeentity - non null entity to insertpublic <E extends T> CompletableFuture<Iterable<E>> insert(Iterable<E> entities)
EntityStoreinsert in interface CompletionStageEntityStore<T>insert in interface EntityStore<T,CompletionStage<?>>E - entity typeentities - to insertpublic <K,E extends T> CompletionStage<K> insert(E entity, Class<K> keyClass)
EntityStorePersistenceException
may be thrown.insert in interface CompletionStageEntityStore<T>insert in interface EntityStore<T,CompletionStage<?>>K - key typeE - entity typeentity - non null entity to insertkeyClass - key classpublic <K,E extends T> CompletionStage<Iterable<K>> insert(Iterable<E> entities, Class<K> keyClass)
EntityStoreinsert in interface CompletionStageEntityStore<T>insert in interface EntityStore<T,CompletionStage<?>>K - key typeE - entity typeentities - to insertkeyClass - key classpublic <E extends T> CompletableFuture<E> update(E entity)
EntityStoreupdate in interface CompletionStageEntityStore<T>update in interface EntityStore<T,CompletionStage<?>>E - entity typeentity - to updatepublic <E extends T> CompletionStage<E> update(E entity, Attribute<?,?>... attributes)
EntityStoreupdate in interface CompletionStageEntityStore<T>update in interface EntityStore<T,CompletionStage<?>>E - entity typeentity - to refreshattributes - attributes to update, attributes should be of type Epublic <E extends T> CompletableFuture<Iterable<E>> update(Iterable<E> entities)
EntityStoreupdate in interface CompletionStageEntityStore<T>update in interface EntityStore<T,CompletionStage<?>>E - entity typeentities - to updatepublic <E extends T> CompletionStage<E> upsert(E entity)
EntityStoreupsert in interface CompletionStageEntityStore<T>upsert in interface EntityStore<T,CompletionStage<?>>E - entity typeentity - non null entity to insertpublic <E extends T> CompletableFuture<Iterable<E>> upsert(Iterable<E> entities)
EntityStoreupsert in interface CompletionStageEntityStore<T>upsert in interface EntityStore<T,CompletionStage<?>>E - entity typeentities - to updatepublic <E extends T> CompletableFuture<E> refresh(E entity)
EntityStorerefresh in interface CompletionStageEntityStore<T>refresh in interface EntityStore<T,CompletionStage<?>>E - entity typeentity - to insertpublic <E extends T> CompletableFuture<E> refresh(E entity, Attribute<?,?>... attributes)
EntityStorerefresh in interface CompletionStageEntityStore<T>refresh in interface EntityStore<T,CompletionStage<?>>E - entity typeentity - to refreshattributes - attributes to refresh, attributes should be of type E
(not enforced due to erasure)public <E extends T> CompletionStage<Iterable<E>> refresh(Iterable<E> entities, Attribute<?,?>... attributes)
EntityStorerefresh in interface CompletionStageEntityStore<T>refresh in interface EntityStore<T,CompletionStage<?>>E - entity typeentities - to refreshattributes - attributes to refresh, attributes should be of type E
(not enforced due to erasure)public <E extends T> CompletableFuture<E> refreshAll(E entity)
EntityStorerefreshAll in interface CompletionStageEntityStore<T>refreshAll in interface EntityStore<T,CompletionStage<?>>E - entity typeentity - to refreshpublic <E extends T> CompletableFuture<Void> delete(E entity)
EntityStoredelete in interface CompletionStageEntityStore<T>delete in interface EntityStore<T,CompletionStage<?>>E - entity type.entity - to deletepublic <E extends T> CompletableFuture<Void> delete(Iterable<E> entities)
EntityStoredelete in interface CompletionStageEntityStore<T>delete in interface EntityStore<T,CompletionStage<?>>E - entity typeentities - to deletepublic <E extends T,K> CompletableFuture<E> findByKey(Class<E> type, K key)
EntityStoreEntityCache if available may be checked first for the object. If an entity is
found in the cache it will be returned and potentially no query will be made.findByKey in interface CompletionStageEntityStore<T>findByKey in interface EntityStore<T,CompletionStage<?>>E - entity typeK - key typetype - non null entity class typekey - non null key valuepublic void close()
EntityStoreResult
instances may throw a PersistenceException.close in interface EntityStore<T,CompletionStage<?>>close in interface AutoCloseablepublic Selection<? extends Result<Tuple>> select(Expression<?>... expressions)
Queryablepublic Selection<? extends Result<Tuple>> select(Set<? extends Expression<?>> expressions)
Queryablepublic Update<? extends Scalar<Integer>> update()
QueryableReturn.get() to perform the operation. The result is the number of rows
affected by the call. Note that aggregate update queries will not affect existing entity
objects in memory.public Deletion<? extends Scalar<Integer>> delete()
QueryableReturn.get() to perform the operation. The result is the number of rows
affected by the call. Note that aggregate update queries will not affect existing entity
objects in memory.public <E extends T> Selection<? extends Result<E>> select(Class<E> type, QueryAttribute<?,?>... attributes)
QueryableResult.public <E extends T> Selection<? extends Result<E>> select(Class<E> type, Set<? extends QueryAttribute<E,?>> attributes)
QueryableResult.public <E extends T> Insertion<? extends Result<Tuple>> insert(Class<E> type)
QueryableReturn.get() to perform the operation. If the type has no generated key values the
result is a tuple containing a single element with the number of rows affected by the
operation. Otherwise if the type has generated keys those keys are returned as the result.public <E extends T> Update<? extends Scalar<Integer>> update(Class<E> type)
QueryableReturn.get() to perform the operation. The result is the number of rows
affected by the call. Note that aggregate update queries will not affect existing entity
objects in memory.public <E extends T> Deletion<? extends Scalar<Integer>> delete(Class<E> type)
QueryableReturn.get() to perform the operation. Note that aggregate delete queries
will not affect existing entity objects in memory or in the EntityCache associated
with the store.public <E extends T> Selection<? extends Scalar<Integer>> count(Class<E> type)
Queryablepublic Selection<? extends Scalar<Integer>> count(QueryAttribute<?,?>... attributes)
Queryablepublic Result<Tuple> raw(String query, Object... parameters)
Queryableraw in interface Queryable<T>query - raw query to executeparameters - query arguments, the number of arguments must match the number of place
holder values in the query or a PersistenceException will be
thrown.Tuple.public <E extends T> Result<E> raw(Class<E> type, String query, Object... parameters)
Queryableraw in interface Queryable<T>E - entity typetype - entity typequery - raw query to executeparameters - query arguments, the number of arguments must match the number of place
holder values in the query or a PersistenceException will be
thrown.public BlockingEntityStore<T> toBlocking()
toBlocking in interface EntityStore<T,CompletionStage<?>>BlockingEntityStore version of this entity store. If the implementation
is already blocking may return itself.