|
||||||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES | |||||||||
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |
java.lang.Objectorg.springframework.orm.jpa.EntityManagerFactoryAccessor
org.springframework.orm.jpa.JpaAccessor
org.springframework.orm.jpa.JpaTemplate
ch.elca.el4j.services.persistence.jpa.dao.ConvenienceJpaTemplate
public class ConvenienceJpaTemplate
This is a convenience class for the Jpa template. Features:
Field Summary |
---|
Fields inherited from class org.springframework.orm.jpa.EntityManagerFactoryAccessor |
---|
logger |
Constructor Summary | |
---|---|
ConvenienceJpaTemplate(javax.persistence.EntityManagerFactory emf)
Constructor. |
Method Summary | ||
---|---|---|
|
findByCriteria(javax.persistence.criteria.CriteriaQuery<T> criteria)
Finds entities matching the given criteria query. |
|
|
findByCriteria(javax.persistence.criteria.CriteriaQuery<T> criteria,
int firstResult,
int maxResults)
Finds entities matching the given criteria query, with paging support. |
|
|
findByIdStrong(Class<T> entityClass,
Serializable id,
String objectName)
Retrieves the persistent instance given by its identifier in a strong way: does the same as the find(Class, java.io.Serializable)
method, but throws a DataRetrievalException instead of
null if the persistent instance could not be found. |
|
|
findByIdStrongLazy(Class<T> entityClass,
Serializable id,
String objectName)
Retrieves the persistent instance given by its identifier in a strong way: does the same as the getReference(Class, java.io.Serializable)
method, but throws a DataRetrievalException instead of
null if the persistent instance could not be found. |
|
int |
getFirstResult()
Gets the id of the first result to return. |
|
Object |
mergeStrong(Object entity,
String objectName)
Merges the given persistent instance in a strong way: does the same as the saveOrUpdate(Object) method, but throws a more
specific OptimisticLockingFailureException in the case of
an optimistic locking failure. |
|
void |
removeAll(Collection<?> entities)
removes all entities in the given collection. |
|
void |
removeStrong(Class<?> entityClass,
Serializable id,
String objectName)
Removes the persistent instance given by its identifier in a strong way: first, the persistent instance is retrieved with the help of the identifier. |
|
void |
setFirstResult(int firstResult)
Sets the id of the first result to return. |
Methods inherited from class org.springframework.orm.jpa.JpaTemplate |
---|
contains, createEntityManagerProxy, execute, execute, executeFind, find, find, find, findByNamedParams, findByNamedQuery, findByNamedQuery, findByNamedQueryAndNamedParams, flush, getReference, isExposeNativeEntityManager, merge, persist, prepareQuery, refresh, remove, setExposeNativeEntityManager |
Methods inherited from class org.springframework.orm.jpa.JpaAccessor |
---|
afterPropertiesSet, flushIfNecessary, getEntityManager, getJpaDialect, isFlushEager, setEntityManager, setFlushEager, setJpaDialect, translateIfNecessary |
Methods inherited from class org.springframework.orm.jpa.EntityManagerFactoryAccessor |
---|
createEntityManager, getEntityManagerFactory, getJpaPropertyMap, getTransactionalEntityManager, setEntityManagerFactory, setJpaProperties, setJpaPropertyMap |
Methods inherited from class java.lang.Object |
---|
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait |
Constructor Detail |
---|
public ConvenienceJpaTemplate(javax.persistence.EntityManagerFactory emf)
emf
- EntityManagerFactory used to create EntityManagerMethod Detail |
---|
public Object mergeStrong(Object entity, String objectName) throws DataAccessException, OptimisticLockingFailureException
saveOrUpdate(Object)
method, but throws a more
specific OptimisticLockingFailureException
in the case of
an optimistic locking failure.
entity
- the persistent entity to save or updateobjectName
- Name of the persistent object type.
DataAccessException
- in case of Hibernate errors
OptimisticLockingFailureException
- in case optimistic locking failsHibernateTemplate.saveOrUpdate(Object)
public int getFirstResult()
public void setFirstResult(int firstResult)
firstResult
- The id of the first result to return.public <T> List<T> findByCriteria(javax.persistence.criteria.CriteriaQuery<T> criteria)
T
- the entity typecriteria
- the criteria query to run against the database
public <T> List<T> findByCriteria(javax.persistence.criteria.CriteriaQuery<T> criteria, int firstResult, int maxResults)
T
- the entity typecriteria
- the criteria query to run against the databasefirstResult
- the index of the first row to returnmaxResults
- the maximum number of rows to return
public <T> T findByIdStrong(Class<T> entityClass, Serializable id, String objectName) throws DataAccessException, DataRetrievalFailureException
find(Class, java.io.Serializable)
method, but throws a DataRetrievalException
instead of
null
if the persistent instance could not be found.
T
- entity typeentityClass
- The class of the object which should be returned.id
- An identifier of the persistent instanceobjectName
- Name of the persistent object type.
DataAccessException
- in case of Jpa persistence exceptions
DataRetrievalFailureException
- in case the persistent instance is nullpublic <T> T findByIdStrongLazy(Class<T> entityClass, Serializable id, String objectName) throws DataAccessException, DataRetrievalFailureException
getReference(Class, java.io.Serializable)
method, but throws a DataRetrievalException
instead of
null
if the persistent instance could not be found.
T
- entity typeentityClass
- The class of the object which should be returned.id
- An identifier of the persistent instanceobjectName
- Name of the persistent object type.
DataAccessException
- in case of Jpa persistence exceptions
DataRetrievalFailureException
- in case the persistent instance is nullpublic void removeStrong(Class<?> entityClass, Serializable id, String objectName) throws DataRetrievalFailureException
DataRetrievalFailureException
will be thrown.
entityClass
- The class of the object which should be deleted.id
- The identifier of the persistent instance to deleteobjectName
- Name of the persistent object type.
DataRetrievalFailureException
- in case the persistent instance to delete is nullJpaTemplate.remove(Object)
public void removeAll(Collection<?> entities)
entities
- the collection of all entities.
|
||||||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES | |||||||||
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |