| 
||||||||||
| PREV CLASS NEXT CLASS | FRAMES NO FRAMES | |||||||||
| SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD | |||||||||
java.lang.Objectorg.springframework.dao.support.DaoSupport
org.springframework.orm.jpa.support.JpaDaoSupport
ch.elca.el4j.services.persistence.jpa.dao.ConvenienceJpaDaoSupport
ch.elca.el4j.services.persistence.jpa.dao.GenericJpaDao<T,ID>
T - The domain class the DAO is responsible forID - The type of the domain class' identifierpublic class GenericJpaDao<T,ID extends Serializable>
This class is a JPA-specific implementation of the ConvenienceGenericDao interface.
| Field Summary | 
|---|
| Fields inherited from class org.springframework.dao.support.DaoSupport | 
|---|
logger | 
| Constructor Summary | |
|---|---|
GenericJpaDao()
Set up the Generic Dao.  | 
|
| Method Summary | |
|---|---|
 void | 
delete(Collection<T> entities)
Deletes the given domain objects.  | 
 void | 
delete(ID id)
Deprecated.  | 
 void | 
delete(T entity)
Deletes the given domain object.  | 
 void | 
deleteAll()
Deletes all available T. | 
 void | 
deleteById(ID id)
Deletes the domain object with the given id, disregarding any concurrent modifications that may have occurred.  | 
protected  List<T> | 
fetchExtent(List<T> objects,
            DataExtent extent)
Prototype of Extent-based fetching, steps through all the retrieved objects and calls the methods of the extent to ensure loading from db.  | 
protected  T | 
fetchExtent(T object,
            DataExtent extent)
Prototype of Extent-based fetching, steps through all the retrieved objects and calls the methods of the extent to ensure loading from db.  | 
 T | 
findById(ID id)
Retrieves a domain object by identifier.  | 
 T | 
findById(ID id,
         DataExtent extent)
Retrieves a domain object by identifier.  | 
 T | 
findByIdLazy(ID id)
 | 
 List<T> | 
findByQuery(QueryBuilder criteria)
Retrieves all the domain objects matching the JPA criteria.  | 
 List<T> | 
findByQuery(QueryBuilder criteria,
            DataExtent extent)
Retrieves all the domain objects matching the JPA criteria.  | 
 List<T> | 
findByQuery(QueryBuilder criteria,
            int firstResult,
            int maxResults)
Retrieves a range of domain objects matching the JPA criteria.  | 
 List<T> | 
findByQuery(QueryBuilder criteria,
            int firstResult,
            int maxResults,
            DataExtent extent)
Retrieves a range of domain objects matching the JPA criteria.  | 
 int | 
findCountByQuery(QueryBuilder criteria)
Retrieves the number of domain objects matching the JPA criteria.  | 
 void | 
flush()
Sometimes, the way Hibernate handles all the actions in a session is very unbelievable.  | 
 List<T> | 
getAll()
Retrieves all the domain objects of type T.  | 
 List<T> | 
getAll(DataExtent extent)
Retrieves all the domain objects of type T.  | 
 ExtentFetcher | 
getExtentFetcher()
 | 
 javax.persistence.criteria.CriteriaQuery<T> | 
getOrderedCriteria()
 | 
 Class<T> | 
getPersistentClass()
Needed because the Java generics throw away this type information.  | 
protected  String | 
getPersistentClassName()
Returns the simple name of the persistent class this DAO is responsible for.  | 
protected  javax.persistence.criteria.CriteriaQuery<T> | 
makeDistinct(javax.persistence.criteria.CriteriaQuery<T> criteria)
 | 
 T | 
merge(T entity)
merge the given entity.  | 
 T | 
persist(T entity)
persist the given entity.  | 
 T | 
refresh(T entity)
Re-reads the state of the given domain object from the underlying store.  | 
 T | 
refresh(T entity,
        DataExtent extent)
Re-reads the state of the given domain object from the underlying store.  | 
 T | 
reload(T entity)
Re-reads the state of the given domain object from the undermost store (eg. the database).  | 
 T | 
reload(T entity,
       DataExtent extent)
Re-reads the state of the given domain object from the undermost store (eg. the database).  | 
 T | 
saveOrUpdate(T entity)
Deprecated.  | 
 T | 
saveOrUpdateAndFlush(T entity)
Deprecated.  | 
 void | 
setExtentFetcher(ExtentFetcher extentFetcher)
 | 
 void | 
setPersistentClass(Class<T> c)
New: this callback is in general no longer required (the constructor figures the type out itself).  | 
| Methods inherited from class ch.elca.el4j.services.persistence.jpa.dao.ConvenienceJpaDaoSupport | 
|---|
createJpaTemplate, getConvenienceJpaTemplate, setConvenienceJpaTemplate | 
| Methods inherited from class org.springframework.orm.jpa.support.JpaDaoSupport | 
|---|
checkDaoConfig, createJpaTemplate, getJpaTemplate, setEntityManager, setEntityManagerFactory, setJpaTemplate | 
| Methods inherited from class org.springframework.dao.support.DaoSupport | 
|---|
afterPropertiesSet, initDao | 
| Methods inherited from class java.lang.Object | 
|---|
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait | 
| Methods inherited from interface org.springframework.beans.factory.InitializingBean | 
|---|
afterPropertiesSet | 
| Constructor Detail | 
|---|
public GenericJpaDao()
| Method Detail | 
|---|
public void setPersistentClass(Class<T> c)
setPersistentClass in interface ConvenienceGenericJpaDao<T,ID extends Serializable>c - Mandatory. The domain class this DAO is responsible for.public Class<T> getPersistentClass()
ConvenienceGenericJpaDao
getPersistentClass in interface ConvenienceGenericJpaDao<T,ID extends Serializable>
@Transactional(propagation=SUPPORTS,
               readOnly=true)
public T findById(ID id)
           throws DataAccessException,
                  DataRetrievalFailureException
findById in interface ConvenienceGenericJpaDao<T,ID extends Serializable>id - The id of the domain object to find
DataRetrievalFailureException - If no domain object could be found with given id.
DataAccessException - If general data access problem occurred
@Transactional(propagation=SUPPORTS,
               readOnly=true)
public T findByIdLazy(ID id)
               throws DataAccessException,
                      DataRetrievalFailureException
DataAccessException
DataRetrievalFailureException
@Transactional(propagation=SUPPORTS,
               readOnly=true)
public List<T> getAll()
               throws DataAccessException
getAll in interface ConvenienceGenericJpaDao<T,ID extends Serializable>DataAccessException - If general data access problem occurred
@Transactional(propagation=SUPPORTS,
               readOnly=true)
public List<T> findByQuery(QueryBuilder criteria)
                    throws DataAccessException
findByQuery in interface ConvenienceGenericJpaDao<T,ID extends Serializable>criteria - the criteria that the result has to fulfill
DataAccessExceptionConvenienceJpaTemplate#findByCriteria(DetachedCriteria)
@Transactional(propagation=SUPPORTS,
               readOnly=true)
public List<T> findByQuery(QueryBuilder criteria,
                                                                    int firstResult,
                                                                    int maxResults)
                    throws DataAccessException
findByQuery in interface ConvenienceGenericJpaDao<T,ID extends Serializable>criteria - the criteria that the result has to fulfillfirstResult - the index of the first result to returnmaxResults - the maximum number of results to return
DataAccessExceptionConvenienceJpaTemplate#findByCriteria(DetachedCriteria, int, int)
@Transactional(propagation=SUPPORTS,
               readOnly=true)
public int findCountByQuery(QueryBuilder criteria)
                     throws DataAccessException
findCountByQuery in interface ConvenienceGenericJpaDao<T,ID extends Serializable>criteria - the criteria that the result has to fulfill
DataAccessExceptionConvenienceJpaTemplate#findCountByCriteria(DetachedCriteria)
@Transactional(propagation=REQUIRED)
public T merge(T entity)
        throws DataAccessException,
               DataIntegrityViolationException,
               OptimisticLockingFailureException
merge in interface ConvenienceGenericJpaDao<T,ID extends Serializable>entity - the entity to merge.
DataAccessException
DataIntegrityViolationException
OptimisticLockingFailureException
@Transactional(propagation=REQUIRED)
public T persist(T entity)
          throws DataAccessException,
                 DataIntegrityViolationException,
                 OptimisticLockingFailureException
persist in interface ConvenienceGenericJpaDao<T,ID extends Serializable>entity - the entity to persist.
DataAccessException
DataIntegrityViolationException
OptimisticLockingFailureException@Deprecated public T saveOrUpdate(T entity)
saveOrUpdate but to
 saveOrUpdateCopy, i.e. you need to use the return value:
 
 dom = dao.saveOrUpdate(dom);
saveOrUpdate in interface ConvenienceGenericJpaDao<T,ID extends Serializable>entity - The domain object to save or update
@Deprecated
@Transactional(propagation=REQUIRED)
public T saveOrUpdateAndFlush(T entity)
                       throws DataAccessException,
                              DataIntegrityViolationException,
                              OptimisticLockingFailureException
saveOrUpdateAndFlush in interface ConvenienceGenericJpaDao<T,ID extends Serializable>entity - The domain object to save or update
DataAccessException
DataIntegrityViolationException
OptimisticLockingFailureException
@Transactional(propagation=REQUIRED)
public void delete(T entity)
            throws DataAccessException
delete in interface ConvenienceGenericJpaDao<T,ID extends Serializable>entity - The domain object to delete
OptimisticLockingFailureException - If domain object has been modified/deleted in the meantime
DataAccessException - If general data access problem occurred
@Transactional(propagation=SUPPORTS,
               readOnly=true)
public T refresh(T entity)
          throws DataAccessException,
                 DataRetrievalFailureException
refresh in interface ConvenienceGenericJpaDao<T,ID extends Serializable>entity - The domain object to re-read the state of
DataAccessException - If general data access problem occurred
DataRetrievalFailureException - If domain object could not be re-read
@Deprecated
@Transactional(propagation=REQUIRED)
public void delete(ID id)
            throws DataAccessException
DataAccessException
@Transactional(propagation=REQUIRED)
public void deleteById(ID id)
                throws DataAccessException
deleteById in interface ConvenienceGenericJpaDao<T,ID extends Serializable>id - The id of the domain object to delete
OptimisticLockingFailureException - If domain object has been deleted in the meantime
DataAccessException - If general data access problem occurred
@Transactional(propagation=REQUIRED)
public void delete(Collection<T> entities)
            throws DataAccessException,
                   DataIntegrityViolationException,
                   OptimisticLockingFailureException
delete in interface ConvenienceGenericJpaDao<T,ID extends Serializable>entities - The domain objects to delete.
DataAccessException - If general data access problem occurred
OptimisticLockingFailureException - If domain object has been modified/deleted in the meantime
DataIntegrityViolationException
@Transactional(propagation=REQUIRED)
public void deleteAll()
               throws OptimisticLockingFailureException,
                      DataAccessException
T.
deleteAll in interface ConvenienceGenericJpaDao<T,ID extends Serializable>OptimisticLockingFailureException - If domain object has been modified/deleted in the meantime
DataAccessException - If general data access problem occurred@Transactional(propagation=REQUIRED) public void flush()
  delete(project);
  project.setId(null) <= to insert new one
  insert(project);
 
 It could cause java.sql.BatchUpdateException:
 ORA-00001: unique constraint BECAUSE Hibernate doesn't flush
 the previous action first.
 This method provides a way to flush manually some action.
 Note that this method is only used in an extremely rare case.
flush in interface ConvenienceGenericJpaDao<T,ID extends Serializable>public javax.persistence.criteria.CriteriaQuery<T> getOrderedCriteria()
protected String getPersistentClassName()
protected javax.persistence.criteria.CriteriaQuery<T> makeDistinct(javax.persistence.criteria.CriteriaQuery<T> criteria)
criteria - the criteria to modify
@Transactional(propagation=SUPPORTS,
               readOnly=true)
public T reload(T entity)
         throws DataAccessException,
                DataRetrievalFailureException
reload in interface ConvenienceGenericJpaDao<T,ID extends Serializable>entity - The domain object to re-load the state of
DataAccessException - If general data access problem occurred
DataRetrievalFailureException - If domain object could not be re-loadedpublic ExtentFetcher getExtentFetcher()
public void setExtentFetcher(ExtentFetcher extentFetcher)
extentFetcher - Is the extentFetcher to set.
protected List<T> fetchExtent(List<T> objects,
                              DataExtent extent)
                       throws DataAccessException
objects - list of objects to load in given extentextent - the fetch-extent
DataAccessException
protected T fetchExtent(T object,
                        DataExtent extent)
                 throws DataAccessException
object - object to load in given extentextent - the fetch-extent
DataAccessException
public List<T> findByQuery(QueryBuilder criteria,
                           DataExtent extent)
                    throws DataAccessException
findByQuery in interface ConvenienceGenericJpaDao<T,ID extends Serializable>criteria - the criteria that the result has to fulfillextent - the extent in which objects get loaded.
DataAccessExceptionConvenienceJpaTemplate#findByCriteria(DetachedCriteria)
public List<T> findByQuery(QueryBuilder criteria,
                           int firstResult,
                           int maxResults,
                           DataExtent extent)
                    throws DataAccessException
findByQuery in interface ConvenienceGenericJpaDao<T,ID extends Serializable>criteria - the criteria that the result has to fulfillfirstResult - the index of the first result to returnmaxResults - the maximum number of results to returnextent - the extent in which objects get loaded.
DataAccessExceptionConvenienceJpaTemplate#findByCriteria(DetachedCriteria, int, int)
public T findById(ID id,
                  DataExtent extent)
           throws DataRetrievalFailureException,
                  DataAccessException
findById in interface ConvenienceGenericJpaDao<T,ID extends Serializable>id - The id of the domain object to findextent - the extent in which objects get loaded.
DataRetrievalFailureException - If no domain object could be found with given id.
DataAccessException - If general data access problem occurred
public List<T> getAll(DataExtent extent)
               throws DataAccessException
getAll in interface ConvenienceGenericJpaDao<T,ID extends Serializable>extent - the extent in which objects get loaded.
DataAccessException - If general data access problem occurred
public T refresh(T entity,
                 DataExtent extent)
          throws DataAccessException,
                 DataRetrievalFailureException
refresh in interface ConvenienceGenericJpaDao<T,ID extends Serializable>entity - The domain object to re-read the state ofextent - the extent in which objects get loaded.
DataAccessException - If general data access problem occurred
DataRetrievalFailureException - If domain object could not be re-read
public T reload(T entity,
                DataExtent extent)
         throws DataAccessException,
                DataRetrievalFailureException
reload in interface ConvenienceGenericJpaDao<T,ID extends Serializable>entity - The domain object to re-read the state ofextent - the extent in which objects get loaded.
DataAccessException - If general data access problem occurred
DataRetrievalFailureException - If domain object could not be re-read
  | 
||||||||||
| PREV CLASS NEXT CLASS | FRAMES NO FRAMES | |||||||||
| SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD | |||||||||