org.perfectjpattern.jee.integration.dao
Class HibernateGenericDao<Id extends Serializable,Element>

java.lang.Object
  extended by org.perfectjpattern.jee.integration.dao.JpaBaseDao<Id,Element>
      extended by org.perfectjpattern.jee.integration.dao.HibernateGenericDao<Id,Element>
Type Parameters:
Id - Identification type
Element - Element type
All Implemented Interfaces:
IBaseDao<Id,Element>, IBaseReadOnlyDao<Id,Element>, IGenericDao<Id,Element>, IGenericReadOnlyDao<Id,Element>
Direct Known Subclasses:
AbstractHibernateManagedGenericDao, SpringGenericDao

public class HibernateGenericDao<Id extends Serializable,Element>
extends JpaBaseDao<Id,Element>
implements IGenericDao<Id,Element>

Hibernate-based implementation of IGenericReadOnlyDao

Version:
$Revision: 1.0 $ $Date: Nov 26, 2007 9:15:14 PM $
Author:
Giovanni Azua
 

Constructor Summary
protected HibernateGenericDao(Class<Element> aPersistentClass, ISessionStrategy aSessionStrategy, ITransactionStrategy aTransactionStrategy)
          Constructs a HibernateGenericDao instance from the persistent class type, the ISessionStrategy that creates Session instances and the ITransactionStrategy that creates Transaction instances
 
Method Summary
 List<Element> findByExample(Element anElement, String... anExcludeProperties)
          Returns the List of Elements that match the search criteria specified through the Example.
protected  org.hibernate.Session getActualSession()
          Returns the Session
 
Methods inherited from class org.perfectjpattern.jee.integration.dao.JpaBaseDao
contains, count, create, delete, deleteAll, findAll, findById, getPersistentClass, getSession, getSessionStrategy, getTransaction, getTransactionStrategy, setEntityManager, update
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 
Methods inherited from interface org.perfectjpattern.jee.api.integration.dao.IBaseDao
create, delete, deleteAll, update
 
Methods inherited from interface org.perfectjpattern.jee.api.integration.dao.IBaseReadOnlyDao
contains, count, findAll, findById, getSession, getTransaction
 

Constructor Detail

HibernateGenericDao

protected HibernateGenericDao(Class<Element> aPersistentClass,
                              ISessionStrategy aSessionStrategy,
                              ITransactionStrategy aTransactionStrategy)
                       throws IllegalArgumentException
Constructs a HibernateGenericDao instance from the persistent class type, the ISessionStrategy that creates Session instances and the ITransactionStrategy that creates Transaction instances

Parameters:
aPersistentClass - The persistent Java Bean class
aSessionStrategy - Factory that creates Sessions
aTransactionStrategy - Factory that creates Transaction
Throws:
IllegalArgumentException
Method Detail

findByExample

public List<Element> findByExample(Element anElement,
                                   String... anExcludeProperties)
                            throws DaoException,
                                   IllegalArgumentException
Returns the List of Elements that match the search criteria specified through the Example. Searches all Elements that match the properties set in the Example Element.

Specified by:
findByExample in interface IGenericReadOnlyDao<Id extends Serializable,Element>
Parameters:
anElement - Example Element to search for.
anExcludeProperties - Array of Java Bean property names to exclude
Returns:
List of Elements that match the search criteria specified through all properties set in the Example.
Throws:
DaoException
IllegalArgumentException - 'anId' must not be null

getActualSession

protected org.hibernate.Session getActualSession()
                                          throws DaoException
Returns the Session

Returns:
the Session
Throws:
DaoException


Copyright © 2007-2009. All Rights Reserved.