T - the type of the domain entityPK - the type of the primary key from the domain entitypublic interface GenericRepository<T extends BaseEntity<PK>,PK extends Serializable> extends Serializable
GenericRepository provide an API for database operations like insert,
delete, update and selections.| Modifier and Type | Method and Description |
|---|---|
void |
create(T entity)
Persists the given entity.
|
javax.persistence.TypedQuery<T> |
createNamedQuery(String name,
Class<T> resultClass)
Factory method for create a new
TypedQuery from the given name and the given type. |
javax.persistence.TypedQuery<T> |
createNamedTypedQuery(String name)
Factory method for create a new
TypedQuery from the given name and the type of the
generic entity. |
void |
delete(List<T> entities)
Delete all persistent entities in the given list.
|
void |
delete(PK id)
Deletes an entity of a given Id.
|
void |
delete(T entity)
Deletes the given entity from persistent storage in the database.
|
void |
evict(T entity)
Remove this instance from the session cache.
|
boolean |
exists(PK id)
Checks if an entry exists with the given id.
|
List<T> |
findAll()
Returns a list of all persistent entities.
|
T |
get(PK id)
Retrieve a persisted entity with a given id from the database.
|
javax.persistence.EntityManager |
getEntityManager()
Gets the entity manager.
|
javax.persistence.Query |
getQuery(String hqlQuery)
Gets a
Query from the given hql query. |
Class<T> |
getType()
Gets the class type.
|
T |
load(PK id)
Retrieve a persisted entity with a given id from the database.
|
List<T> |
merge(List<T> entities)
Merges all new entities in the given list.
|
T |
merge(T entity)
Merges the given entity.
|
void |
refresh(T entity)
Re-read the state of the given instance from the underlying database.
|
List<PK> |
save(List<T> entities)
Save all new entities in the given list.
|
PK |
save(T entity)
Persist the given entity into database.
|
void |
saveOrUpdate(List<T> entities)
Save or update all transient entities in the given list.
|
void |
saveOrUpdate(T entity)
Save or update the given persistent entity.
|
void |
setEntityManager(javax.persistence.EntityManager entityManager)
Sets the entity manager.
|
void |
update(List<T> entities)
Update all transient entities in the given list.
|
void |
update(T entity)
Update changes made to the given entity.
|
void create(T entity)
entity - the entityjavax.persistence.TypedQuery<T> createNamedQuery(String name, Class<T> resultClass)
TypedQuery from the given name and the given type.name - the nameresultClass - the result classTypedQueryjavax.persistence.TypedQuery<T> createNamedTypedQuery(String name)
TypedQuery from the given name and the type of the
generic entity.name - the nameTypedQueryvoid delete(List<T> entities)
entities - the list with the persistent entities to deletevoid delete(PK id)
id - the idvoid delete(T entity)
entity - the persistent entityvoid evict(T entity)
entity - the entity to evict.boolean exists(PK id)
id - the id to checkList<T> findAll()
T get(PK id)
id - the idjavax.persistence.EntityManager getEntityManager()
javax.persistence.Query getQuery(String hqlQuery)
Query from the given hql query.hqlQuery - the hql queryQueryT load(PK id)
id - the idList<T> merge(List<T> entities)
entities - the list to saveT merge(T entity)
entity - the entityvoid refresh(T entity)
entity - the entity to re-read.List<PK> save(List<T> entities)
entities - the list to savePK save(T entity)
entity - the new instance to save.void saveOrUpdate(List<T> entities)
entities - the transient entitiesvoid saveOrUpdate(T entity)
entity - the transient entity to save or update.void setEntityManager(javax.persistence.EntityManager entityManager)
entityManager - the new entity managervoid update(List<T> entities)
entities - the transient entities to update.void update(T entity)
entity - the transient entity to update.Copyright © 2015–2018 Alpha Ro Group UG (haftungsbeschrÀngt). All rights reserved.