lumis.portal.dao.hibernate
Class GenericHibernateManualUpdateDao<T,ID extends Serializable>

Package class diagram package GenericHibernateManualUpdateDao
java.lang.Object
  extended by lumis.portal.dao.hibernate.GenericHibernateManualUpdateDao<T,ID>
Direct Known Subclasses:
CategoryDaoHib, DouiDaoHib, ModelDaoHib, PageDaoHib, ReportDaoHib, ScheduleDaoHib, ServiceDaoHib, ServiceInterfaceDaoHib, ServiceInterfaceMenuGroupTypeDaoHib, ServiceInterfaceMenuItemTypeDaoHib, SubscriptionDaoHib

public abstract class GenericHibernateManualUpdateDao<T,ID extends Serializable>
extends Object

Implements the generic CRUD data access operations using Hibernate APIs.

The instances returned by this class do not automatically persist changes to its state. The method update(Object, ITransaction) must be called to do it.

To write a DAO, subclass and parameterize this class with your persistent class. Of course, assuming that you have a traditional 1:1 approach for Entity:DAO design.

You have to inject the Class object of the persistent class to construct a DAO.

Since:
4.0.11

Constructor Summary
protected GenericHibernateManualUpdateDao(Class<T> persistentClass)
           
 
Method Summary
protected  void add(T bean, ITransaction transaction)
          Adds the bean to the persistence layer.
protected  void addOrUpdate(T bean, ITransaction transaction)
           
protected  boolean delete(ID id, ITransaction transaction)
          Deletes the bean with the given id from persistence.
protected  void evict(ID id, ITransaction transaction)
          Evicts the bean with the given id from the second-level cache.
protected  List<T> findByCriteria(ITransaction transaction, org.hibernate.criterion.Criterion... criterions)
          Convenience method for subclasses.
protected  List<T> findByCriteria(ITransaction transaction, org.hibernate.criterion.Criterion[] criterions, org.hibernate.criterion.Order[] orders)
          Convenience method for subclasses.
protected  T get(ID id, ITransaction transaction)
          Returns the bean with the given id.
protected abstract  ID getIdentifier(T bean)
           
protected  Class<T> getPersistentClass()
          Returns the class whose persistence this DAO controls.
protected  void setReadOnly(ITransaction transaction, Collection<T> beans)
          Sets a collection of beans to read-only state.
protected  void update(T bean, ITransaction transaction)
           
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Constructor Detail

GenericHibernateManualUpdateDao

protected GenericHibernateManualUpdateDao(Class<T> persistentClass)
Method Detail

getIdentifier

protected abstract ID getIdentifier(T bean)

getPersistentClass

protected Class<T> getPersistentClass()
Returns the class whose persistence this DAO controls.


get

protected T get(ID id,
                ITransaction transaction)
         throws PortalObjectNotFoundException,
                PortalException
Returns the bean with the given id. The bean is set as read-only, so changes on it won't persist automatically.

Parameters:
id - the bean's id.
transaction - the transaction for persistence access. Must be a ITransactionHibernate.
Returns:
the bean.
Throws:
PortalObjectNotFoundException - if the corresponding bean does not exist in the persistence.
PortalException

add

protected void add(T bean,
                   ITransaction transaction)
            throws PortalException
Adds the bean to the persistence layer.

Parameters:
bean - the bean to be added.
transaction - the transaction for persistence access.
Throws:
PortalException

update

protected void update(T bean,
                      ITransaction transaction)
               throws PortalException
Throws:
PortalException

addOrUpdate

protected void addOrUpdate(T bean,
                           ITransaction transaction)
                    throws PortalException
Throws:
PortalException

delete

protected boolean delete(ID id,
                         ITransaction transaction)
                  throws PortalException
Deletes the bean with the given id from persistence.

Parameters:
id - the bean's id.
transaction - the transaction for persistence access. Must be a ITransactionHibernate.
Returns:
true if the bean was deleted, or false if it did not exist
Throws:
PortalException

evict

protected void evict(ID id,
                     ITransaction transaction)
              throws PortalException
Evicts the bean with the given id from the second-level cache.

Parameters:
id - the bean identifier.
transaction - the transaction for persistence access.
Throws:
PortalException
Since:
4.0.11

setReadOnly

protected void setReadOnly(ITransaction transaction,
                           Collection<T> beans)
                    throws DaoException
Sets a collection of beans to read-only state.

Throws:
DaoException

findByCriteria

protected List<T> findByCriteria(ITransaction transaction,
                                 org.hibernate.criterion.Criterion[] criterions,
                                 org.hibernate.criterion.Order[] orders)
                          throws DaoException
Convenience method for subclasses. All returned entities are returned in read-only state.

Throws:
DaoException

findByCriteria

protected List<T> findByCriteria(ITransaction transaction,
                                 org.hibernate.criterion.Criterion... criterions)
                          throws DaoException
Convenience method for subclasses. All returned entities are returned in read-only state.

Throws:
DaoException


Lumisportal  4.1.0.071221 - Copyright © 2001-2007, Lumis. All Rights Reserved.