Class JPAGenericDAO<K,E>

java.lang.Object
fr.paris.lutece.util.jpa.JPAGenericDAO<K,E>
Type Parameters:
K - Type of the entity's key
E - Type of the entity
All Implemented Interfaces:
IGenericDAO<K,E>
Direct Known Subclasses:
JPALuteceDAO

public abstract class JPAGenericDAO<K,E> extends Object implements IGenericDAO<K,E>
Class JPAGenericDAO
  • Constructor Summary

    Constructors
    Constructor
    Description
    Constructor
  • Method Summary

    Modifier and Type
    Method
    Description
    void
    create(E entity)
    Create an entity
    void
    detach(E entity)
    Remove the given entity from the persistence context, causing a managed entity to become detached.
    Find all entities
    findById(K key)
    Find an entity by its Id
    void
    Synchronize the persistence context to the underlying database.
    javax.persistence.EntityManager
    Return the Entity Manager
    Gets the entity class
    Returns the entity class name
    abstract javax.persistence.EntityManagerFactory
    Inherit classes should provide their Entity Manager Factory
    void
    remove(K key)
    Remove an entity
    void
    update(E entity)
    Update an entity

    Methods inherited from class java.lang.Object

    equals, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
  • Constructor Details

    • JPAGenericDAO

      public JPAGenericDAO()
      Constructor
  • Method Details

    • getEntityManagerFactory

      public abstract javax.persistence.EntityManagerFactory getEntityManagerFactory()
      Inherit classes should provide their Entity Manager Factory
      Returns:
      The Entity Manager Factory that will create Entity Manager for this DAO
    • getEntityClassName

      public String getEntityClassName()
      Returns the entity class name
      Returns:
      The entity class name
    • getEntityClass

      public Class<E> getEntityClass()
      Gets the entity class
      Returns:
      the entity class
    • getEM

      public javax.persistence.EntityManager getEM()
      Return the Entity Manager
      Returns:
      The Entity Manager
    • create

      public void create(E entity)
      Create an entity
      Specified by:
      create in interface IGenericDAO<K,E>
      Parameters:
      entity - The entity to create
    • remove

      public void remove(K key)
      Remove an entity
      Specified by:
      remove in interface IGenericDAO<K,E>
      Parameters:
      key - The key of the entity to remove
    • update

      public void update(E entity)
      Update an entity
      Specified by:
      update in interface IGenericDAO<K,E>
      Parameters:
      entity - An entity that contains new values
    • findById

      public E findById(K key)
      Find an entity by its Id
      Specified by:
      findById in interface IGenericDAO<K,E>
      Parameters:
      key - The entity key
      Returns:
      The entity object
    • findAll

      public List<E> findAll()
      Find all entities
      Specified by:
      findAll in interface IGenericDAO<K,E>
      Returns:
      A list of entities
    • flush

      public void flush()
      Synchronize the persistence context to the underlying database.
      Specified by:
      flush in interface IGenericDAO<K,E>
    • detach

      public void detach(E entity)
      Remove the given entity from the persistence context, causing a managed entity to become detached.
      Specified by:
      detach in interface IGenericDAO<K,E>
      Parameters:
      entity - the entity