Package ejava.examples.daoex.dao
Class JPANativeSQLBookDAO
- java.lang.Object
-
- ejava.examples.daoex.dao.JPANativeSQLBookDAO
-
-
Field Summary
Fields Modifier and Type Field Description private EntityManager
em
-
Constructor Summary
Constructors Constructor Description JPANativeSQLBookDAO()
-
Method Summary
All Methods Instance Methods Concrete Methods Modifier and Type Method Description Book
create(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.Book
get(long id)
Gets a book from the database by its ID.void
remove(Book book)
Removes a book from the database.void
setEntityManager(EntityManager em)
Book
update(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:BookDAO
Add the book to the database.- Specified by:
create
in interfaceBookDAO
- Throws:
PersistenceException
-
update
public Book update(Book book) throws PersistenceException
Description copied from interface:BookDAO
Updates the book in the database with the values in this object.- Specified by:
update
in interfaceBookDAO
- Throws:
PersistenceException
-
get
public Book get(long id) throws PersistenceException
Description copied from interface:BookDAO
Gets a book from the database by its ID.- Specified by:
get
in interfaceBookDAO
- Throws:
PersistenceException
-
remove
public void remove(Book book) throws PersistenceException
Description copied from interface:BookDAO
Removes a book from the database.- Specified by:
remove
in interfaceBookDAO
- Throws:
PersistenceException
-
findAll
public List<Book> findAll(int start, int count) throws PersistenceException
Description copied from interface:BookDAO
Returns a collection of books, starting at the index provided and limiting the collection to the count value.- Specified by:
findAll
in interfaceBookDAO
- Throws:
PersistenceException
-
-