Home
Creating an entity manager
The session bean works with the JPA entities to access the ITSOBANK database. We require an entity manager bound to the persistent context.
Add these definitions to the EJBBankBean class: @PersistenceContext (unitName="RAD75JPA",
type=PersistenceContextType.TRANSACTION)
private EntityManager entityMgr;
The @PersistenceContext annotation defines the persistence context unit with transactional behavior. The unit name matches the name in the persistence.xml file in the RAD75JPA project:
<persistence-unit name="RAD75JPA">
The EntityManager instance is used to execute JPA methods to retrieve, insert, update, delete, and query instances.
Organize imports (select the javax.persistence package).
ibm.com/redbooks