|
||||||||||
| PREV CLASS NEXT CLASS | FRAMES NO FRAMES | |||||||||
| SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD | |||||||||
java.lang.Objectnet.craftforge.essential.example.persistence.CrudDao<T>
T - The entity typepublic class CrudDao<T>
A CRUD DAO generalizes the simple create, read, update and delete methods for entities of a given type. Each operations opens, commits and closes transactions itself.
Do not use this DAO for a sequence of operations if they shall share one transaction.
| Constructor Summary | |
|---|---|
CrudDao(javax.persistence.EntityManager entityManager)
Initializes the CRUD DAO with the entity manager to use for its operations. |
|
| Method Summary | |
|---|---|
T |
createEntity(T entity)
Creates an entity by making it persistent. |
void |
deleteEntity(Class<T> clazz,
Integer id)
Deletes an entity of the given class with the specified id by removing it from the persistence context. |
T |
readEntity(Class<T> clazz,
Integer id)
Reads an entity of the given class with the specified id by finding it in the the persistence context. |
protected void |
requireExistence(T entity)
Requires the existence of an entity. |
T |
updateEntity(Integer id,
T entity)
Updates an entity by merging it into the persistence context. |
| Methods inherited from class java.lang.Object |
|---|
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait |
| Constructor Detail |
|---|
public CrudDao(javax.persistence.EntityManager entityManager)
entityManager - The entity manager| Method Detail |
|---|
public T createEntity(T entity)
throws net.craftforge.essential.controller.ControllerException
entity - The entity to persist
net.craftforge.essential.controller.ControllerException - if the entity has already been persistent
public T updateEntity(Integer id,
T entity)
throws net.craftforge.essential.controller.ControllerException
id - The entity identity - The entity to merge
net.craftforge.essential.controller.ControllerException - if no entity with the given id has already been persistent
public void deleteEntity(Class<T> clazz,
Integer id)
throws net.craftforge.essential.controller.ControllerException
clazz - The entity classid - The entity id
net.craftforge.essential.controller.ControllerException - if no entity with the given id has already been persistent
public T readEntity(Class<T> clazz,
Integer id)
throws net.craftforge.essential.controller.ControllerException
clazz - The entity classid - The entity id
net.craftforge.essential.controller.ControllerException - if no entity with the given id has already been persistent
protected void requireExistence(T entity)
throws net.craftforge.essential.controller.ControllerException
entity - The entity
net.craftforge.essential.controller.ControllerException - if the entity is null
|
||||||||||
| PREV CLASS NEXT CLASS | FRAMES NO FRAMES | |||||||||
| SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD | |||||||||