Using application-managed persistence

Application-managed persistence is useful when special handling of persistence is required such as the explicit management of an EntityManager life cycle or more explicit control over Java Transaction API (JTA) transactions is needed. Application-managed persistence is the focus of this recipe.

Getting ready

The essential process for using application-managed persistence involves:

  1. Injecting an EntityManagerFactory to provide a means to create an EntityManager
  2. Creating the EntityManager to control the persistence process
  3. Using the EntityManager method to manage the entity

How to do it...

Create a new Java EE application called ApplicationManagedPersistenceApplication. In this application we will only use the WAR ...

Get EJB 3.1 Cookbook now with O’Reilly online learning.

O’Reilly members experience live online training, plus books, videos, and digital content from 200+ publishers.