Class GenericHibernateDao<T,​ID extends java.io.Serializable>


  • public abstract class GenericHibernateDao<T,​ID extends java.io.Serializable>
    extends java.lang.Object
    Implements the generic CRUD data access operations using Hibernate APIs.
    Since:
    4.0.11
    Version:
    $Revision$ $Date$
    • Constructor Summary

      Constructors 
      Modifier Constructor Description
      protected GenericHibernateDao​(java.lang.Class<T> persistentClass)
      Create a new DAO instance for beans of the specified class.
    • Method Summary

      All Methods Instance Methods Concrete Methods 
      Modifier and Type Method Description
      void delete​(T bean, ITransaction transaction)
      Deletes the given bean from persistence.
      protected java.util.List<T> findByCriteria​(ITransaction transaction, org.hibernate.criterion.Criterion... criterions)
      Utility find method for subclasses.
      protected java.util.List<T> findByCriteria​(ITransaction transaction, org.hibernate.criterion.Criterion[] criterions, org.hibernate.criterion.Order[] orders)
      Utility find method for subclasses.
      T get​(ID id, ITransaction transaction)
      Returns the bean with the given id.
      protected java.lang.Class<T> getPersistentClass()
      Returns the class whose persistence this DAO controls.
      protected org.hibernate.Session getSession​(ITransaction transaction)
      Returns the hibernate session associated with the given transaction.
      void persist​(T bean, ITransaction transaction)
      Persists a transient bean, making it persistent.
      • Methods inherited from class java.lang.Object

        clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
    • Constructor Detail

      • GenericHibernateDao

        protected GenericHibernateDao​(java.lang.Class<T> persistentClass)
        Create a new DAO instance for beans of the specified class.
        Parameters:
        persistentClass - the hibernate entity class.
        Since:
        4.0.11
    • Method Detail

      • getPersistentClass

        protected java.lang.Class<T> getPersistentClass()
        Returns the class whose persistence this DAO controls.
        Since:
        4.0.11
      • getSession

        protected org.hibernate.Session getSession​(ITransaction transaction)
                                            throws PortalException
        Returns the hibernate session associated with the given transaction.
        Parameters:
        transaction - the transaction.
        Returns:
        the session.
        Throws:
        PortalException
        Since:
        4.0.11
      • persist

        public void persist​(T bean,
                            ITransaction transaction)
                     throws PortalException
        Persists a transient bean, making it persistent.
        Parameters:
        bean - the bean to be made persistent.
        transaction - the transaction for persistence access.
        Throws:
        PortalException
        Since:
        4.0.11
      • delete

        public void delete​(T bean,
                           ITransaction transaction)
                    throws PortalException
        Deletes the given bean from persistence.
        Parameters:
        bean - the persistent bean.
        transaction - the transaction for persistence access.
        Throws:
        PortalException
        Since:
        4.0.11
      • findByCriteria

        protected java.util.List<T> findByCriteria​(ITransaction transaction,
                                                   org.hibernate.criterion.Criterion[] criterions,
                                                   org.hibernate.criterion.Order[] orders)
                                            throws DaoException
        Utility find method for subclasses.
        Parameters:
        transaction - transaction for persistence access.
        criterions - criterions used to find the result.
        orders - specifies the order by which the results will be ordered.
        Returns:
        a list with the beans found.
        Throws:
        DaoException
        Since:
        4.0.11
      • findByCriteria

        protected java.util.List<T> findByCriteria​(ITransaction transaction,
                                                   org.hibernate.criterion.Criterion... criterions)
                                            throws DaoException
        Utility find method for subclasses.
        Parameters:
        transaction - transaction for persistence access.
        criterions - criterions used to find the result.
        Returns:
        a list with the beans found.
        Throws:
        DaoException
        Since:
        4.0.11