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 EntityManager
em
private static org.slf4j.Logger
logger
-
Constructor Summary
Constructors Constructor Description JPAAuthorDAO()
-
Method Summary
All Methods Instance Methods Concrete Methods Modifier and Type Method Description void
create(Author author)
Author
get(long id)
Author
getByQuery(long id)
void
remove(Author author)
void
setEntityManager(EntityManager em)
Author
update(Author author)
Author
updateByMerge(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:
getByQuery
in interfaceAuthorDAO
-
update
public Author update(Author author) throws DAOException
- Specified by:
update
in interfaceAuthorDAO
- Throws:
DAOException
-
updateByMerge
public Author updateByMerge(Author author)
- Specified by:
updateByMerge
in interfaceAuthorDAO
-
-