Package lumis.portal.dao.hibernate
Class GenericHibernateManualUpdateDao<T,ID extends java.io.Serializable>
- java.lang.Object
-
- lumis.portal.dao.hibernate.GenericHibernateManualUpdateDao<T,ID>
-
- Direct Known Subclasses:
CategoryDaoHib
,DouiDaoHib
,ModelDaoHib
,PageDaoHib
,ScheduleDaoHib
,ServiceDaoHib
,ServiceInterfaceDaoHib
,ServiceInterfaceMenuGroupTypeDaoHib
,ServiceInterfaceMenuItemTypeDaoHib
,SubscriptionDaoHib
public abstract class GenericHibernateManualUpdateDao<T,ID extends java.io.Serializable> extends java.lang.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
- Version:
- $Revision$ $Date$
-
-
Constructor Summary
Constructors Modifier Constructor Description protected
GenericHibernateManualUpdateDao(java.lang.Class<T> persistentClass)
-
Method Summary
All Methods Instance Methods Abstract Methods Concrete Methods Modifier and Type Method Description 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 boolean
exists(ID id, ITransaction transaction)
Returns whether the bean of identifierid
exists.protected java.util.List<T>
findByCriteria(ITransaction transaction, org.hibernate.criterion.Criterion... criterions)
Convenience method for subclasses.protected java.util.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 java.lang.Class<T>
getPersistentClass()
Returns the class whose persistence this DAO controls.protected void
setReadOnly(ITransaction transaction, java.util.Collection<T> beans)
Sets a collection of beans to read-only state.protected void
update(T bean, ITransaction transaction)
-
-
-
Constructor Detail
-
GenericHibernateManualUpdateDao
protected GenericHibernateManualUpdateDao(java.lang.Class<T> persistentClass)
-
-
Method Detail
-
getPersistentClass
protected java.lang.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 aITransactionHibernate
.- 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
-
exists
protected boolean exists(ID id, ITransaction transaction) throws PortalException
Returns whether the bean of identifierid
exists.- Parameters:
id
- the bean identifier.transaction
- the transacion to be used.- Returns:
- whether the bean of identifier
id
exists. - Throws:
PortalException
- Since:
- 8.0.0
-
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 aITransactionHibernate
.- 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, java.util.Collection<T> beans) throws DaoException
Sets a collection of beans to read-only state.- Throws:
DaoException
-
findByCriteria
protected java.util.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 java.util.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
-
-