|
||||||||||
| PREV CLASS NEXT CLASS | FRAMES NO FRAMES | |||||||||
| SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD | |||||||||
java.lang.Objectbr.gov.frameworkdemoiselle.template.JPACrud<T,I>
T - bean object typeI - bean id typepublic class JPACrud<T,I>
JPA specific implementation for Crud interface.
Crud,
Serialized Form| Constructor Summary | |
|---|---|
JPACrud()
|
|
| Method Summary | |
|---|---|
protected javax.persistence.criteria.CriteriaQuery<T> |
createCriteriaQuery()
|
protected javax.persistence.Query |
createQuery(String ql)
|
void |
delete(I id)
Finds an instance of this entity by it's primary ID and asks to the persistence provider to remove this entity instance from the persistence context. |
List<T> |
findAll()
|
protected List<T> |
findByCriteriaQuery(javax.persistence.criteria.CriteriaQuery<T> criteriaQuery)
Search CriteriaQuery integrated into the context of paging |
protected List<T> |
findByExample(T example)
Retrieves a list of entities based on a single example instance of it. |
protected List<T> |
findByJPQL(String jpql)
Search JPQL integrated into the context of paging |
protected Class<T> |
getBeanClass()
|
protected javax.persistence.criteria.CriteriaBuilder |
getCriteriaBuilder()
|
protected javax.persistence.EntityManager |
getEntityManager()
|
protected Pagination |
getPagination()
|
protected void |
handleException(Throwable cause)
|
T |
insert(T entity)
Insert a new instance of the entity in the database. |
T |
load(I id)
|
T |
update(T entity)
Merge all changes made to the passed entity to a managed entity. |
| Methods inherited from class java.lang.Object |
|---|
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait |
| Constructor Detail |
|---|
public JPACrud()
| Method Detail |
|---|
protected Class<T> getBeanClass()
protected javax.persistence.criteria.CriteriaBuilder getCriteriaBuilder()
protected javax.persistence.EntityManager getEntityManager()
protected Pagination getPagination()
protected javax.persistence.criteria.CriteriaQuery<T> createCriteriaQuery()
protected javax.persistence.Query createQuery(String ql)
protected void handleException(Throwable cause)
throws Throwable
Throwablepublic T insert(T entity)
insert in interface Crud<T,I>entity - A non-detached instance of an entity. If this instance is not managed, it will be after this method returns.
javax.persistence.EntityExistsException - if entity is an unmanaged instance
and the persistence provider already has a persisted instance that matches the entity's primary key.
IllegalArgumentException - if the instance is not an entityEntityManager.persist(Object entity)public void delete(I id)
delete in interface Crud<T,I>EntityManager.remove(Object entity)public T update(T entity)
update in interface Crud<T,I>public T load(I id)
load in interface Crud<T,I>public List<T> findAll()
findAll in interface Crud<T,I>protected List<T> findByJPQL(String jpql)
jpql - - query in syntax JPQL
protected List<T> findByCriteriaQuery(javax.persistence.criteria.CriteriaQuery<T> criteriaQuery)
criteriaQuery - - structure CriteriaQuery
protected List<T> findByExample(T example)
See below a sample of its usage:
Employee example = new Employee(); example.setId(12345); return (List<Employee>) findByExample(example);
example - an entity example
|
||||||||||
| PREV CLASS NEXT CLASS | FRAMES NO FRAMES | |||||||||
| SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD | |||||||||