ch.elca.el4j.services.persistence.generic.dao
Interface ConvenienceGenericDao<T,ID extends Serializable>

Type Parameters:
T - The generic type of the domain class the DAO is responsible for
ID - The generic type of the domain class' identifier
All Superinterfaces:
GenericDao<T>
All Known Subinterfaces:
ConvenienceGenericHibernateDao<T,ID>, ConvenienceIdentityFixedDao<T,ID>
All Known Implementing Classes:
GenericHibernateDao

public interface ConvenienceGenericDao<T,ID extends Serializable>
extends GenericDao<T>

Extends the GenericDao with a few convenience methods. As EL4J only supports Hibernate as persistence framework it's more convenient to use ConvenienceGenericHibernateDao directly.

Author:
Philipp Oser (POS), Alex Mathey (AMA), Martin Zeltner (MZE)
File-location:
ConvenienceGenericDao
Last check-in date:
2009-08-17 14:34:48 +0200 (Mo, 17. Aug 2009) by swismer for revision 3902

Method Summary
 void delete(ID id)
          Deprecated. Renamed to deleteById as of el4j 1.6
 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.
 T findById(ID id)
          Retrieves a domain object by identifier.
 T findByIdLazy(ID id)
          Retrieves a domain object by identifier lazily.
 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.
 
Methods inherited from interface ch.elca.el4j.services.persistence.generic.dao.GenericDao
delete, findByQuery, findCountByQuery, getPersistentClass, refresh, reload, saveOrUpdate, setPersistentClass
 

Method Detail

findById

T findById(ID id)
           throws DataRetrievalFailureException,
                  DataAccessException
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.

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

findByIdLazy

T findByIdLazy(ID id)
               throws DataRetrievalFailureException,
                      DataAccessException
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.

Throws:
DataRetrievalFailureException
DataAccessException
See Also:
findById

delete

@Deprecated
void delete(ID id)
            throws OptimisticLockingFailureException,
                   DataAccessException
Deprecated. Renamed to deleteById as of el4j 1.6

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

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

void deleteById(ID id)
                throws OptimisticLockingFailureException,
                       DataAccessException
Deletes the domain object with the given id, disregarding any concurrent modifications that may have occurred.

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

getAll

List<T> getAll()
               throws DataAccessException
Retrieves all the domain objects of type T.

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

delete

void delete(T entity)
            throws OptimisticLockingFailureException,
                   DataAccessException
Deletes the given domain object.

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

deleteAll

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

Throws:
OptimisticLockingFailureException - If domain object has been modified/deleted in the meantime
DataAccessException - If general data access problem occurred

flush

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.



Copyright © 2005-2011 ELCA. All Rights Reserved.