ch.elca.el4j.services.persistence.hibernate.dao
Class GenericHibernateDao<T,ID extends Serializable>

java.lang.Object
  extended by org.springframework.dao.support.DaoSupport
      extended by org.springframework.orm.hibernate3.support.HibernateDaoSupport
          extended by ch.elca.el4j.services.persistence.hibernate.dao.ConvenienceHibernateDaoSupport
              extended by ch.elca.el4j.services.persistence.hibernate.dao.GenericHibernateDao<T,ID>
Type Parameters:
T - The domain class the DAO is responsible for
ID - The type of the domain class' identifier
All Implemented Interfaces:
ConvenienceGenericDao<T,ID>, GenericDao<T>, ConvenienceGenericHibernateDao<T,ID>, InitializingBean

public class GenericHibernateDao<T,ID extends Serializable>
extends ConvenienceHibernateDaoSupport
implements ConvenienceGenericHibernateDao<T,ID>, InitializingBean

This class is a Hibernate-specific implementation of the ConvenienceGenericDao interface.

Author:
Philipp Oser (POS), Alex Mathey (AMA), Jonas Hauenstein (JHN)
File-location:
GenericHibernateDao
Last check-in date:
2010-09-20 15:55:50 +0200 (Mo, 20. Sep 2010) by sstelca for revision 4173

Field Summary
 
Fields inherited from class org.springframework.dao.support.DaoSupport
logger
 
Constructor Summary
GenericHibernateDao()
          Set up the Generic Dao.
 
Method Summary
protected  DetachedCriteria addOrder(DetachedCriteria criteria)
           
 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 deleteAllNoCascade()
          Deletes all available T using a HQL query.
 void deleteById(ID id)
          Deletes the domain object with the given id, disregarding any concurrent modifications that may have occurred.
 void deleteNoCascade(Collection<T> entities)
          Deletes the given domain objects using a HQL query.
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.
 List<T> findByCriteria(DetachedCriteria hibernateCriteria)
          Retrieves all the domain objects matching the Hibernate criteria.
 List<T> findByCriteria(DetachedCriteria hibernateCriteria, DataExtent extent)
          Retrieves all the domain objects matching the Hibernate criteria.
 List<T> findByCriteria(DetachedCriteria hibernateCriteria, int firstResult, int maxResults)
          Retrieves a range of domain objects matching the Hibernate criteria.
 List<T> findByCriteria(DetachedCriteria hibernateCriteria, int firstResult, int maxResults, DataExtent extent)
          Retrieves a range of domain objects matching the Hibernate criteria.
 T findById(ID id)
          Retrieves a domain object by identifier.
 T findById(ID id, boolean lock)
          Retrieves a domain object by identifier, optionally obtaining a database lock for this operation.
 T findById(ID id, boolean lock, DataExtent extent)
          Retrieves a domain object by identifier, optionally obtaining a database lock for this operation.
 T findById(ID id, DataExtent extent)
          Retrieves a domain object by identifier.
 T findByIdLazy(ID id)
          Retrieves a domain object by identifier lazily.
 List<T> findByQuery(QueryObject q)
          Executes a query based on a given query object.
 List<T> findByQuery(QueryObject q, DataExtent extent)
          Executes a query based on a given query object.
 int findCountByCriteria(DetachedCriteria hibernateCriteria)
          Retrieves the number of domain objects matching the Hibernate criteria.
 int findCountByQuery(QueryObject q)
          Count number of results of a search.
 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.
protected  DetachedCriteria getCriteria(QueryObject queryObject)
           
 Order[] getDefaultOrder()
          
 DetachedCriteria getOrderedCriteria()
          Create a DetachedCriteria what contains default ordering and distinct constraints.
 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  DetachedCriteria makeDistinct(DetachedCriteria criteria)
           
 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)
          Saves or updates the given domain object.
 T saveOrUpdateAndFlush(T entity)
          Convenience method: Executes saveOrUpdate() and flush() on that entity.
 void setDefaultOrder(Order... defaultOrder)
          Set default order of results returned by getAll and findByQuery (not findByCriteria!).
 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.hibernate.dao.ConvenienceHibernateDaoSupport
createHibernateTemplate, getConvenienceHibernateTemplate, setConvenienceHibernateTemplate
 
Methods inherited from class org.springframework.orm.hibernate3.support.HibernateDaoSupport
checkDaoConfig, convertHibernateAccessException, getHibernateTemplate, getSession, getSession, getSessionFactory, releaseSession, setHibernateTemplate, setSessionFactory
 
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

GenericHibernateDao

public GenericHibernateDao()
Set up the Generic Dao. Auto-derive the parametrized type.

Method Detail

setPersistentClass

public void setPersistentClass(Class<T> c)
New: this callback is in general no longer required (the constructor figures the type out itself).

Specified by:
setPersistentClass in interface GenericDao<T>
Parameters:
c - Mandatory. The domain class this DAO is responsible for.

getPersistentClass

public Class<T> getPersistentClass()
Description copied from interface: GenericDao
Needed because the Java generics throw away this type information.

Specified by:
getPersistentClass in interface GenericDao<T>
Returns:
Returns the domain class this DAO is responsible for.

getDefaultOrder

public Order[] getDefaultOrder()

Specified by:
getDefaultOrder in interface ConvenienceGenericHibernateDao<T,ID extends Serializable>
Returns:
the default Order to order the results

setDefaultOrder

public void setDefaultOrder(Order... defaultOrder)
Set default order of results returned by getAll and findByQuery (not findByCriteria!). If defaultOrder is null then default ordering is deactivated.

Specified by:
setDefaultOrder in interface ConvenienceGenericHibernateDao<T,ID extends Serializable>
Parameters:
defaultOrder - the default Order to order the results

findById

@Transactional(propagation=SUPPORTS,
               readOnly=true)
public T findById(ID id,
                                                           boolean lock)
           throws DataAccessException,
                  DataRetrievalFailureException
Retrieves a domain object by identifier, optionally obtaining a database lock for this operation.
(For hibernate specialists: we do a "get()" in this method. In case you require only a "load()" (e.g. for lazy loading to work) we recommend that you write your own find method in the interface's subclass.)

Parameters:
id - The id of a domain object
lock - Indicates whether a database lock should be obtained for this operation
Returns:
The desired domain object
Throws:
DataAccessException - If general data access problem occurred
DataRetrievalFailureException - If domain object could not be retrieved

findById

@Transactional(propagation=REQUIRED,
               readOnly=true)
public T findById(ID id,
                                                           boolean lock,
                                                           DataExtent extent)
           throws DataAccessException,
                  DataRetrievalFailureException
Retrieves a domain object by identifier, optionally obtaining a database lock for this operation.
(For hibernate specialists: we do a "get()" in this method. In case you require only a "load()" (e.g. for lazy loading to work) we recommend that you write your own find method in the interface's subclass.) Loads at least the given extent.

Specified by:
findById in interface ConvenienceGenericHibernateDao<T,ID extends Serializable>
Parameters:
id - The id of a domain object
lock - Indicates whether a database lock should be obtained for this operation
extent - the extent in which objects get loaded.
Returns:
The desired domain object
Throws:
DataAccessException - If general data access problem occurred
DataRetrievalFailureException - If domain object could not be retrieved

findById

@Transactional(propagation=SUPPORTS,
               readOnly=true)
public T findById(ID id)
           throws DataAccessException,
                  DataRetrievalFailureException
Retrieves a domain object by identifier. This method gets the object from the hibernate cache. It might be that you don't get the actual version that is in the database. If you want the actual version do a refresh() after this method call.

Specified by:
findById in interface ConvenienceGenericDao<T,ID extends Serializable>
Parameters:
id - The id of the domain object to find
Returns:
Returns the found domain object.
Throws:
DataRetrievalFailureException - If no domain object could be found with given id.
DataAccessException - If general data access problem occurred

findById

@Transactional(propagation=REQUIRED,
               readOnly=true)
public T findById(ID id,
                                                           DataExtent extent)
           throws DataAccessException,
                  DataRetrievalFailureException
Retrieves a domain object by identifier. This method gets the object from the hibernate cache. It might be that you don't get the actual version that is in the database. If you want the actual version do a refresh() after this method call. Loads at least the given extent.

Specified by:
findById in interface ConvenienceGenericHibernateDao<T,ID extends Serializable>
Parameters:
id - The id of the domain object to find
extent - the extent in which objects get loaded.
Returns:
Returns the found domain object.
Throws:
DataRetrievalFailureException - If no domain object could be found with given id.
DataAccessException - If general data access problem occurred

findByIdLazy

@Transactional(propagation=SUPPORTS,
               readOnly=true)
public T findByIdLazy(ID id)
               throws DataAccessException,
                      DataRetrievalFailureException
Retrieves a domain object by identifier lazily. It uses Hibernate lazy loading, namely the method load() instead of get(). For detailed information about fetching strategies see http://www.hibernate.org/hib_docs/v3/reference/en/html/performance.html.

Specified by:
findByIdLazy in interface ConvenienceGenericDao<T,ID extends Serializable>
Throws:
DataAccessException
DataRetrievalFailureException
See Also:
findById

getAll

@Transactional(propagation=SUPPORTS,
               readOnly=true)
public List<T> getAll()
               throws DataAccessException
Retrieves all the domain objects of type T.

Specified by:
getAll in interface ConvenienceGenericDao<T,ID extends Serializable>
Returns:
The list containing all the domain objects of type T; if no such domain objects exist, an empty list will be returned
Throws:
DataAccessException - If general data access problem occurred

getAll

@Transactional(propagation=REQUIRED,
               readOnly=true)
public List<T> getAll(DataExtent extent)
               throws DataAccessException
Retrieves all the domain objects of type T. Loads at least the given extent.

Specified by:
getAll in interface ConvenienceGenericHibernateDao<T,ID extends Serializable>
Parameters:
extent - the extent in which objects get loaded.
Returns:
The list containing all the domain objects of type T; if no such domain objects exist, an empty list will be returned
Throws:
DataAccessException - If general data access problem occurred

findByQuery

@Transactional(propagation=SUPPORTS,
               readOnly=true)
public List<T> findByQuery(QueryObject q)
                    throws DataAccessException
Executes a query based on a given query object. This method may also support paging (see javadoc of implementing class). This method supports paging (see QueryObject for info on how to use this).

Specified by:
findByQuery in interface GenericDao<T>
Parameters:
q - The search query object
Returns:
A list containing 0 or more domain objects
Throws:
DataAccessException - If general data access problem occurred

findByQuery

@Transactional(propagation=REQUIRED,
               readOnly=true)
public List<T> findByQuery(QueryObject q,
                                                                    DataExtent extent)
                    throws DataAccessException
Executes a query based on a given query object. This method may also support paging (see javadoc of implementing class). Loads at least the given extent. This method supports paging (see QueryObject for info on how to use this).

Specified by:
findByQuery in interface ConvenienceGenericHibernateDao<T,ID extends Serializable>
Parameters:
q - The search query object
extent - the extent in which objects get loaded.
Returns:
A list containing 0 or more domain objects
Throws:
DataAccessException - If general data access problem occurred

findCountByQuery

@Transactional(propagation=SUPPORTS,
               readOnly=true)
public int findCountByQuery(QueryObject q)
                     throws DataAccessException
Count number of results of a search. This method supports paging (see QueryObject for info on how to use this).

Specified by:
findCountByQuery in interface GenericDao<T>
Parameters:
q - The search query object
Returns:
how many elements do we find with the given query
Throws:
DataAccessException

findByCriteria

@Transactional(propagation=SUPPORTS,
               readOnly=true)
public List<T> findByCriteria(DetachedCriteria hibernateCriteria)
                       throws DataAccessException
Retrieves all the domain objects matching the Hibernate criteria.

Specified by:
findByCriteria in interface ConvenienceGenericHibernateDao<T,ID extends Serializable>
Parameters:
hibernateCriteria - the criteria that the result has to fulfill Note: Do not reuse criteria objects! They need to recreated (or cloned e.g. using SerializationUtils.clone()) per execution, due to the suboptimal design of Hibernate's criteria facility.
Returns:
all object that fulfill the criteria
Throws:
DataAccessException
See Also:
HibernateTemplate.findByCriteria(DetachedCriteria)

findByCriteria

@Transactional(propagation=REQUIRED,
               readOnly=true)
public List<T> findByCriteria(DetachedCriteria hibernateCriteria,
                                                                       DataExtent extent)
                       throws DataAccessException
Retrieves all the domain objects matching the Hibernate criteria. Loads at least the given extent.

Specified by:
findByCriteria in interface ConvenienceGenericHibernateDao<T,ID extends Serializable>
Parameters:
hibernateCriteria - the criteria that the result has to fulfill Note: Do not reuse criteria objects! They need to recreated (or cloned e.g. using SerializationUtils.clone()) per execution, due to the suboptimal design of Hibernate's criteria facility.
extent - the extent in which objects get loaded.
Returns:
all object that fulfill the criteria
Throws:
DataAccessException
See Also:
HibernateTemplate.findByCriteria(DetachedCriteria)

findByCriteria

@Transactional(propagation=SUPPORTS,
               readOnly=true)
public List<T> findByCriteria(DetachedCriteria hibernateCriteria,
                                                                       int firstResult,
                                                                       int maxResults)
                       throws DataAccessException
Retrieves a range of domain objects matching the Hibernate criteria.

Specified by:
findByCriteria in interface ConvenienceGenericHibernateDao<T,ID extends Serializable>
Parameters:
hibernateCriteria - the criteria that the result has to fulfill Note: Do not reuse criteria objects! They need to recreated (or cloned e.g. using SerializationUtils.clone()) per execution, due to the suboptimal design of Hibernate's criteria facility.
firstResult - the index of the first result to return
maxResults - the maximum number of results to return
Returns:
the specified subset of object that fulfill the criteria
Throws:
DataAccessException
See Also:
HibernateTemplate.findByCriteria(DetachedCriteria, int, int)

findByCriteria

@Transactional(propagation=REQUIRED,
               readOnly=true)
public List<T> findByCriteria(DetachedCriteria hibernateCriteria,
                                                                       int firstResult,
                                                                       int maxResults,
                                                                       DataExtent extent)
                       throws DataAccessException
Retrieves a range of domain objects matching the Hibernate criteria. Loads at least the given extent.

Specified by:
findByCriteria in interface ConvenienceGenericHibernateDao<T,ID extends Serializable>
Parameters:
hibernateCriteria - the criteria that the result has to fulfill Note: Do not reuse criteria objects! They need to recreated (or cloned e.g. using SerializationUtils.clone()) per execution, due to the suboptimal design of Hibernate's criteria facility.
firstResult - the index of the first result to return
maxResults - the maximum number of results to return
extent - the extent in which objects get loaded.
Returns:
the specified subset of object that fulfill the criteria
Throws:
DataAccessException
See Also:
HibernateTemplate.findByCriteria(DetachedCriteria, int, int)

findCountByCriteria

@Transactional(propagation=SUPPORTS,
               readOnly=true)
public int findCountByCriteria(DetachedCriteria hibernateCriteria)
                        throws DataAccessException
Retrieves the number of domain objects matching the Hibernate criteria.

Specified by:
findCountByCriteria in interface ConvenienceGenericHibernateDao<T,ID extends Serializable>
Parameters:
hibernateCriteria - the criteria that the result has to fulfill Note: Do not reuse criteria objects! They need to recreated (or cloned e.g. using SerializationUtils.clone()) per execution, due to the suboptimal design of Hibernate's criteria facility.
Returns:
the number of objects that fulfill the criteria
Throws:
DataAccessException
See Also:
ConvenienceHibernateTemplate.findCountByCriteria(DetachedCriteria)

saveOrUpdate

@Transactional(propagation=REQUIRED)
public T saveOrUpdate(T entity)
               throws DataAccessException,
                      DataIntegrityViolationException,
                      OptimisticLockingFailureException
Saves or updates the given domain object.

Specified by:
saveOrUpdate in interface GenericDao<T>
Parameters:
entity - The domain object to save or update
Returns:
The saved or updated domain object
Throws:
DataAccessException - If general data access problem occurred
DataIntegrityViolationException - If domain object could not be inserted due to a data integrity violation
OptimisticLockingFailureException - If domain object has been modified/deleted in the meantime

saveOrUpdateAndFlush

@Transactional(propagation=REQUIRED)
public T saveOrUpdateAndFlush(T entity)
                       throws DataAccessException,
                              DataIntegrityViolationException,
                              OptimisticLockingFailureException
Convenience method: Executes saveOrUpdate() and flush() on that entity.

Specified by:
saveOrUpdateAndFlush in interface ConvenienceGenericHibernateDao<T,ID extends Serializable>
Parameters:
entity - The domain object to save or update
Returns:
The saved or updated object
Throws:
DataAccessException
DataIntegrityViolationException
OptimisticLockingFailureException

delete

@Transactional(propagation=REQUIRED)
public void delete(T entity)
            throws DataAccessException
Deletes the given domain object.

Specified by:
delete in interface ConvenienceGenericDao<T,ID extends Serializable>
Parameters:
entity - The domain object to delete
Throws:
OptimisticLockingFailureException - If domain object has been modified/deleted in the meantime
DataAccessException - If general data access problem occurred

refresh

@Transactional(propagation=SUPPORTS,
               readOnly=true)
public T refresh(T entity)
          throws DataAccessException,
                 DataRetrievalFailureException
Re-reads the state of the given domain object from the underlying store.

Specified by:
refresh in interface GenericDao<T>
Parameters:
entity - The domain object to re-read the state of
Returns:
The refreshed entity
Throws:
DataAccessException - If general data access problem occurred
DataRetrievalFailureException - If domain object could not be re-read

refresh

@Transactional(propagation=REQUIRED,
               readOnly=true)
public T refresh(T entity,
                                                          DataExtent extent)
          throws DataAccessException,
                 DataRetrievalFailureException
Re-reads the state of the given domain object from the underlying store. Loads at least the given extent.

Specified by:
refresh in interface ConvenienceGenericHibernateDao<T,ID extends Serializable>
Parameters:
entity - The domain object to re-read the state of
extent - the extent in which objects get loaded.
Returns:
The refreshed entity
Throws:
DataAccessException - If general data access problem occurred
DataRetrievalFailureException - If domain object could not be re-read

reload

@Transactional(propagation=SUPPORTS,
               readOnly=true)
public T reload(T entity)
         throws DataAccessException,
                DataRetrievalFailureException
Re-reads the state of the given domain object from the undermost store (eg. the database).

Specified by:
reload in interface GenericDao<T>
Parameters:
entity - The domain object to re-load the state of
Returns:
The reloaded entity
Throws:
DataAccessException - If general data access problem occurred
DataRetrievalFailureException - If domain object could not be re-loaded

reload

@Transactional(propagation=REQUIRED,
               readOnly=true)
public T reload(T entity,
                                                         DataExtent extent)
         throws DataAccessException,
                DataRetrievalFailureException
Re-reads the state of the given domain object from the undermost store (eg. the database). Loads at least the given extent.

Specified by:
reload in interface ConvenienceGenericHibernateDao<T,ID extends Serializable>
Parameters:
entity - The domain object to re-read the state of
extent - the extent in which objects get loaded.
Returns:
The refreshed entity
Throws:
DataAccessException - If general data access problem occurred
DataRetrievalFailureException - If domain object could not be re-read

delete

@Deprecated
@Transactional(propagation=REQUIRED)
public void delete(ID id)
            throws DataAccessException
Deprecated. 

Deletes the domain object with the given id, disregarding any concurrent modifications that may have occurred.

Specified by:
delete in interface ConvenienceGenericDao<T,ID extends Serializable>
Parameters:
id - The id of the domain object to delete
Throws:
OptimisticLockingFailureException - If domain object has been deleted in the meantime
DataAccessException - If general data access problem occurred

deleteById

@Transactional(propagation=REQUIRED)
public void deleteById(ID id)
                throws DataAccessException
Deletes the domain object with the given id, disregarding any concurrent modifications that may have occurred.

Specified by:
deleteById in interface ConvenienceGenericDao<T,ID extends Serializable>
Parameters:
id - The id of the domain object to delete
Throws:
OptimisticLockingFailureException - If domain object has been deleted in the meantime
DataAccessException - If general data access problem occurred

delete

public void delete(Collection<T> entities)
            throws DataAccessException,
                   DataIntegrityViolationException,
                   OptimisticLockingFailureException
Deletes the given domain objects. This method executed in a single transaction (by default with the Required semantics).

Specified by:
delete in interface GenericDao<T>
Parameters:
entities - The domain objects to delete.
Throws:
DataAccessException - If general data access problem occurred
OptimisticLockingFailureException - If domain object has been modified/deleted in the meantime
DataIntegrityViolationException

deleteNoCascade

public void deleteNoCascade(Collection<T> entities)
                     throws DataAccessException,
                            DataIntegrityViolationException,
                            OptimisticLockingFailureException
Deletes the given domain objects using a HQL query. This has the benefit of a significant performance improvement in comparison to delete. The tradeoff is that this method does no cascade deletion.

Specified by:
deleteNoCascade in interface ConvenienceGenericHibernateDao<T,ID extends Serializable>
Parameters:
entities - The domain objects to delete.
Throws:
OptimisticLockingFailureException - If domain object has been modified/deleted in the meantime
DataAccessException - If general data access problem occurred
DataIntegrityViolationException

deleteAll

public void deleteAll()
               throws OptimisticLockingFailureException,
                      DataAccessException
Deletes all available T.

Specified by:
deleteAll in interface ConvenienceGenericDao<T,ID extends Serializable>
Throws:
OptimisticLockingFailureException - If domain object has been modified/deleted in the meantime
DataAccessException - If general data access problem occurred

deleteAllNoCascade

public void deleteAllNoCascade()
                        throws OptimisticLockingFailureException,
                               DataAccessException
Deletes all available T using a HQL query. This has the benefit of a significant performance improvement in comparison to deleteAll. The tradeoff is that this method does no cascade deletion.

Specified by:
deleteAllNoCascade in interface ConvenienceGenericHibernateDao<T,ID extends Serializable>
Throws:
OptimisticLockingFailureException - If domain object has been modified/deleted in the meantime
DataAccessException - If general data access problem occurred

flush

@Transactional(propagation=REQUIRED)
public void flush()
Sometimes, the way Hibernate handles all the actions in a session is very unbelievable. For example, we call 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.

Specified by:
flush in interface ConvenienceGenericDao<T,ID extends Serializable>

getOrderedCriteria

public DetachedCriteria getOrderedCriteria()
Create a DetachedCriteria what contains default ordering and distinct constraints.

Specified by:
getOrderedCriteria in interface ConvenienceGenericHibernateDao<T,ID extends Serializable>
Returns:
a DetachedCriteria

fetchExtent

protected List<T> fetchExtent(List<T> objects,
                              DataExtent extent)
                       throws DataAccessException
Prototype of Extent-based fetching, steps through all the retrieved objects and calls the methods of the extent to ensure loading from db.

Parameters:
objects - list of objects to load in given extent
extent - the fetch-extent
Returns:
returns the new list of objects.
Throws:
DataAccessException

fetchExtent

protected T fetchExtent(T object,
                        DataExtent extent)
                 throws DataAccessException
Prototype of Extent-based fetching, steps through all the retrieved objects and calls the methods of the extent to ensure loading from db.

Parameters:
object - object to load in given extent
extent - the fetch-extent
Returns:
returns the new object.
Throws:
DataAccessException

getPersistentClassName

protected String getPersistentClassName()
Returns the simple name of the persistent class this DAO is responsible for.

Returns:
The simple name of the persistent class this DAO is responsible for.

getCriteria

protected DetachedCriteria getCriteria(QueryObject queryObject)
Parameters:
queryObject - an EL4J QueryObject that should be converted to a DetachedCriteria
Returns:
a suitable DetachedCriteria

addOrder

protected DetachedCriteria addOrder(DetachedCriteria criteria)
Parameters:
criteria - the criteria to modify
Returns:
the criteria enhanced with order constraints (if set using setDefaultOrder)

makeDistinct

protected DetachedCriteria makeDistinct(DetachedCriteria criteria)
Parameters:
criteria - the criteria to modify
Returns:
the criteria enhanced with distinct restrictions


Copyright © 2005-2011 ELCA. All Rights Reserved.