Class GenericDAOJPAImpl<E,I extends Serializable>

java.lang.Object
org.exoplatform.commons.persistence.impl.GenericDAOJPAImpl<E,I>
Type Parameters:
E - Entity type
I - Identity of the entity
All Implemented Interfaces:
org.exoplatform.commons.api.persistence.GenericDAO<E,I>
Direct Known Subclasses:
SettingContextDAO, SettingScopeDAO, SettingsDAO

public class GenericDAOJPAImpl<E,I extends Serializable> extends Object implements org.exoplatform.commons.api.persistence.GenericDAO<E,I>
Version:
$Revision$
Author:
Trong Tran
  • Field Details

    • modelClass

      protected Class<E> modelClass
  • Constructor Details

    • GenericDAOJPAImpl

      public GenericDAOJPAImpl()
  • Method Details

    • count

      public Long count()
      Specified by:
      count in interface org.exoplatform.commons.api.persistence.GenericDAO<E,I extends Serializable>
    • find

      public E find(I id)
      Specified by:
      find in interface org.exoplatform.commons.api.persistence.GenericDAO<E,I extends Serializable>
    • findAll

      public List<E> findAll()
      This method makes 2 calls to getEntityManager(): 1- The first one to get the CriteriaBuilder 2- The second one to create the query If there is no EntityManager in the threadLocal (i.e: EntityManagerService.getEntityManager() returns null), the EntityManagerHolder will return 2 distinct EntityManager instances. This will result in a org.hibernate.SessionException: Session is closed!. Thus, this method shall always be invoked with an EntityManager in the ThreadLocal (for example, from a request managed by the portal lifecycle or from a method annotated with @ExoTransactional)
      Specified by:
      findAll in interface org.exoplatform.commons.api.persistence.GenericDAO<E,I extends Serializable>
    • create

      public E create(E entity)
      Specified by:
      create in interface org.exoplatform.commons.api.persistence.GenericDAO<E,I extends Serializable>
    • createAll

      public void createAll(List<E> entities)
      Specified by:
      createAll in interface org.exoplatform.commons.api.persistence.GenericDAO<E,I extends Serializable>
    • update

      public E update(E entity)
      Specified by:
      update in interface org.exoplatform.commons.api.persistence.GenericDAO<E,I extends Serializable>
    • updateAll

      public void updateAll(List<E> entities)
      Specified by:
      updateAll in interface org.exoplatform.commons.api.persistence.GenericDAO<E,I extends Serializable>
    • delete

      public void delete(E entity)
      Specified by:
      delete in interface org.exoplatform.commons.api.persistence.GenericDAO<E,I extends Serializable>
    • deleteAll

      public void deleteAll(List<E> entities)
      Specified by:
      deleteAll in interface org.exoplatform.commons.api.persistence.GenericDAO<E,I extends Serializable>
    • deleteAll

      public void deleteAll()
      Specified by:
      deleteAll in interface org.exoplatform.commons.api.persistence.GenericDAO<E,I extends Serializable>
    • getEntityManager

      protected jakarta.persistence.EntityManager getEntityManager()
      Return an EntityManager instance.
      Returns:
      An EntityManger instance.
    • getHibernateDialect

      protected org.hibernate.dialect.Dialect getHibernateDialect()
    • isMSSQLDialect

      protected boolean isMSSQLDialect()
    • isOrcaleDialect

      protected boolean isOrcaleDialect()