br.gov.frameworkdemoiselle.template
Class JPACrud<T,I>

java.lang.Object
  extended by br.gov.frameworkdemoiselle.template.JPACrud<T,I>
Type Parameters:
T - bean object type
I - bean id type
All Implemented Interfaces:
Crud<T,I>, Serializable

public class JPACrud<T,I>
extends Object
implements Crud<T,I>

JPA specific implementation for Crud interface.

Author:
SERPRO
See Also:
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)
           
 List<T> findAll()
           
 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)
           
 void insert(T entity)
           
 T load(I id)
           
 void update(T entity)
           
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Constructor Detail

JPACrud

public JPACrud()
Method Detail

getBeanClass

protected Class<T> getBeanClass()

getCriteriaBuilder

protected javax.persistence.criteria.CriteriaBuilder getCriteriaBuilder()

getEntityManager

protected javax.persistence.EntityManager getEntityManager()

getPagination

protected Pagination getPagination()

createCriteriaQuery

protected javax.persistence.criteria.CriteriaQuery<T> createCriteriaQuery()

createQuery

protected javax.persistence.Query createQuery(String ql)

handleException

protected void handleException(Throwable cause)
                        throws Throwable
Throws:
Throwable

insert

public void insert(T entity)
Specified by:
insert in interface Crud<T,I>

delete

public void delete(I id)
Specified by:
delete in interface Crud<T,I>

update

public void update(T entity)
Specified by:
update in interface Crud<T,I>

load

public T load(I id)
Specified by:
load in interface Crud<T,I>

findAll

public List<T> findAll()
Specified by:
findAll in interface Crud<T,I>

findByJPQL

protected List<T> findByJPQL(String jpql)
Search JPQL integrated into the context of paging

Parameters:
jpql - - query in syntax JPQL
Returns:
a list of entities

findByCriteriaQuery

public List<T> findByCriteriaQuery(javax.persistence.criteria.CriteriaQuery<T> criteriaQuery)
Search CriteriaQuery integrated into the context of paging

Parameters:
criteriaQuery - - structure CriteriaQuery
Returns:
a list of entities

findByExample

protected List<T> findByExample(T example)
Retrieves a list of entities based on a single example instance of it.

See below a sample of its usage:

 Employee example = new Employee();
 example.setId(12345);
 return (List<Employee>) findByExample(example);
 

Parameters:
example - an entity example
Returns:
a list of entities


Copyright © 2012 SERPRO - Serviço Federal de Processamento de Dados. All Rights Reserved.