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.
The essential process for using application-managed persistence involves:
- Injecting an
EntityManagerFactoryto provide a means to create an
- Creating the
EntityManagerto control the persistence process
- Using the
EntityManagermethod 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 ...