Package ejava.examples.daoex.dao
Class JPANativeSQLBookDAO
- java.lang.Object
-
- ejava.examples.daoex.dao.JPANativeSQLBookDAO
-
-
Field Summary
Fields Modifier and Type Field Description private EntityManagerem
-
Constructor Summary
Constructors Constructor Description JPANativeSQLBookDAO()
-
Method Summary
All Methods Instance Methods Concrete Methods Modifier and Type Method Description Bookcreate(Book book)Add the book to the database.List<Book>findAll(int start, int count)Returns a collection of books, starting at the index provided and limiting the collection to the count value.Bookget(long id)Gets a book from the database by its ID.voidremove(Book book)Removes a book from the database.voidsetEntityManager(EntityManager em)Bookupdate(Book book)Updates the book in the database with the values in this object.
-
-
-
Field Detail
-
em
private EntityManager em
-
-
Method Detail
-
setEntityManager
public void setEntityManager(EntityManager em)
-
create
public Book create(Book book) throws PersistenceException
Description copied from interface:BookDAOAdd the book to the database.- Specified by:
createin interfaceBookDAO- Throws:
PersistenceException
-
update
public Book update(Book book) throws PersistenceException
Description copied from interface:BookDAOUpdates the book in the database with the values in this object.- Specified by:
updatein interfaceBookDAO- Throws:
PersistenceException
-
get
public Book get(long id) throws PersistenceException
Description copied from interface:BookDAOGets a book from the database by its ID.- Specified by:
getin interfaceBookDAO- Throws:
PersistenceException
-
remove
public void remove(Book book) throws PersistenceException
Description copied from interface:BookDAORemoves a book from the database.- Specified by:
removein interfaceBookDAO- Throws:
PersistenceException
-
findAll
public List<Book> findAll(int start, int count) throws PersistenceException
Description copied from interface:BookDAOReturns a collection of books, starting at the index provided and limiting the collection to the count value.- Specified by:
findAllin interfaceBookDAO- Throws:
PersistenceException
-
-