T - bean object typeI - bean id typepublic class JPACrud<T,I> extends Object implements Crud<T,I>
Crud,
Serialized Form| Constructor and Description |
|---|
JPACrud() |
| Modifier and Type | Method and Description |
|---|---|
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.
|
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)
public 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)
public T update(T entity)
protected List<T> findByJPQL(String jpql)
jpql - - query in syntax JPQLprotected List<T> findByCriteriaQuery(javax.persistence.criteria.CriteriaQuery<T> criteriaQuery)
criteriaQuery - - structure CriteriaQueryprotected 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 exampleCopyright © 2019 SERPRO - Serviço Federal de Processamento de Dados. All rights reserved.