T
- the base class or interface to restrict all entities that are stored to (e.g.
Persistable
or Object
or Serializable
for instance.
The purpose is to aid in the prevention of runtime errors by restricting the types at
compile time.R
- the operation return type. For an asynchronous implementation may return a
Future
or other type of promise representing the result
of the operation.public interface EntityStore<T,R> extends Queryable<T>, AutoCloseable
Entity
objects. This interface supports the
basic insert/update/delete operations.Modifier and Type | Method and Description |
---|---|
void |
close()
Close the entity store.
|
<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(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> |
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.
|
BlockingEntityStore<T> |
toBlocking() |
<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.
|
void close()
Result
instances may throw a PersistenceException
.close
in interface AutoCloseable
<E extends T> R insert(E entity)
PersistenceException
may be thrown.E
- entity typeentity
- non null entity to insert<E extends T> R insert(Iterable<E> entities)
E
- entity typeentities
- to insert<K,E extends T> R insert(E entity, Class<K> keyClass)
PersistenceException
may be thrown.K
- key typeE
- entity typeentity
- non null entity to insertkeyClass
- key class<K,E extends T> R insert(Iterable<E> entities, Class<K> keyClass)
K
- key typeE
- entity typeentities
- to insertkeyClass
- key class<E extends T> R update(E entity)
E
- entity typeentity
- to update<E extends T> R update(Iterable<E> entities)
E
- entity typeentities
- to update<E extends T> R update(E entity, Attribute<?,?>... attributes)
E
- entity typeentity
- to refreshattributes
- attributes to update, attributes should be of type E<E extends T> R upsert(E entity)
E
- entity typeentity
- non null entity to insert<E extends T> R upsert(Iterable<E> entities)
E
- entity typeentities
- to update<E extends T> R refresh(E entity)
E
- entity typeentity
- to insert<E extends T> R refresh(E entity, Attribute<?,?>... attributes)
E
- entity typeentity
- to refreshattributes
- attributes to refresh, attributes should be of type E
(not enforced due to erasure)<E extends T> R refresh(Iterable<E> entities, Attribute<?,?>... attributes)
E
- entity typeentities
- to refreshattributes
- attributes to refresh, attributes should be of type E
(not enforced due to erasure)<E extends T> R refreshAll(E entity)
E
- entity typeentity
- to refresh<E extends T> R delete(E entity)
E
- entity type.entity
- to delete<E extends T> R delete(Iterable<E> entities)
E
- entity typeentities
- to delete@CheckReturnValue <E extends T,K> R findByKey(Class<E> type, K key)
EntityCache
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.E
- entity typeK
- key typetype
- non null entity class typekey
- non null key value@CheckReturnValue BlockingEntityStore<T> toBlocking()
BlockingEntityStore
version of this entity store. If the implementation
is already blocking may return itself.