Package fr.paris.lutece.util.jpa
Class JPAGenericDAO<K,E>
- java.lang.Object
-
- fr.paris.lutece.util.jpa.JPAGenericDAO<K,E>
-
- Type Parameters:
K- Type of the entity's keyE- Type of the entity
- All Implemented Interfaces:
IGenericDAO<K,E>
- Direct Known Subclasses:
JPALuteceDAO
public abstract class JPAGenericDAO<K,E> extends java.lang.Object implements IGenericDAO<K,E>
Class JPAGenericDAO
-
-
Constructor Summary
Constructors Constructor Description JPAGenericDAO()Constructor
-
Method Summary
All Methods Instance Methods Abstract Methods Concrete Methods Modifier and Type Method Description voidcreate(E entity)Create an entityvoiddetach(E entity)Remove the given entity from the persistence context, causing a managed entity to become detached.java.util.List<E>findAll()Find all entitiesEfindById(K key)Find an entity by its Idvoidflush()Synchronize the persistence context to the underlying database.javax.persistence.EntityManagergetEM()Return the Entity Managerjava.lang.Class<E>getEntityClass()Gets the entity classjava.lang.StringgetEntityClassName()Returns the entity class nameabstract javax.persistence.EntityManagerFactorygetEntityManagerFactory()Inherit classes should provide their Entity Manager Factoryvoidremove(K key)Remove an entityvoidupdate(E entity)Update an entity
-
-
-
Method Detail
-
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 java.lang.String getEntityClassName()
Returns the entity class name- Returns:
- The entity class name
-
getEntityClass
public java.lang.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:
createin interfaceIGenericDAO<K,E>- Parameters:
entity- The entity to create
-
remove
public void remove(K key)
Remove an entity- Specified by:
removein interfaceIGenericDAO<K,E>- Parameters:
key- The key of the entity to remove
-
update
public void update(E entity)
Update an entity- Specified by:
updatein interfaceIGenericDAO<K,E>- Parameters:
entity- An entity that contains new values
-
findById
public E findById(K key)
Find an entity by its Id- Specified by:
findByIdin interfaceIGenericDAO<K,E>- Parameters:
key- The entity key- Returns:
- The entity object
-
findAll
public java.util.List<E> findAll()
Find all entities- Specified by:
findAllin interfaceIGenericDAO<K,E>- Returns:
- A list of entities
-
flush
public void flush()
Synchronize the persistence context to the underlying database.- Specified by:
flushin interfaceIGenericDAO<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:
detachin interfaceIGenericDAO<K,E>- Parameters:
entity- the entity
-
-