Package ejava.examples.daoex.jpa
Class JPAAuthorDAO
- java.lang.Object
-
- ejava.examples.daoex.jpa.JPAAuthorDAO
-
- All Implemented Interfaces:
AuthorDAO
public class JPAAuthorDAO extends Object implements AuthorDAO
This class implements a DAO using javax.persistence.EntityManager. Most of the work of mapping the objects to the database is being performed in either the @Entity class or in a orm.xml descriptor file. The caller of this object must manage the transaction scope. The EntityManager is being injected into the DAO at the start of the overall transaction.
-
-
Field Summary
Fields Modifier and Type Field Description private EntityManageremprivate static org.slf4j.Loggerlogger
-
Constructor Summary
Constructors Constructor Description JPAAuthorDAO()
-
Method Summary
All Methods Instance Methods Concrete Methods Modifier and Type Method Description voidcreate(Author author)Authorget(long id)AuthorgetByQuery(long id)voidremove(Author author)voidsetEntityManager(EntityManager em)Authorupdate(Author author)AuthorupdateByMerge(Author author)
-
-
-
Field Detail
-
logger
private static final org.slf4j.Logger logger
-
em
private EntityManager em
-
-
Method Detail
-
setEntityManager
public void setEntityManager(EntityManager em)
-
getByQuery
public Author getByQuery(long id)
- Specified by:
getByQueryin interfaceAuthorDAO
-
update
public Author update(Author author) throws DAOException
- Specified by:
updatein interfaceAuthorDAO- Throws:
DAOException
-
updateByMerge
public Author updateByMerge(Author author)
- Specified by:
updateByMergein interfaceAuthorDAO
-
-