A Java Persistence API entity manager handles how entities within a
are found, created, and removed.
Entities within a persistence context are associated with an entity manager instance.
The entity manager instance controls how the entities in a persistence context are managed.
You can use an entity manager instance to handle locating the entities in a persistence context.
Types of Entity Managers
Entity managers can be container-managed or application-managed.
The type of entity manager you can use in your application depends upon the container and how transactions are carried out.
You specify how transactions are carried out in the persistence unit.
Container-managed entity manager.
You can use a container-managed entity manager if you are deploying to a Java EE 5 container.
In this case, transactions are carried out using Java Transaction Architecture (JTA).
When using a container-managed entity manager, all entities are managed by the container.
Application-managed entity manager.
You must use an application-managed entity manager if you explicitly manage the lifecycle of the entity manager.
In this case, transactions can be carried out using JTA or explicitly by the application (resource-local entity manager).
When using an application-managed entity manager, the persistence context and the lifecycle of EntityManager instances are managed by the application.
For more on entity managers, see the Java EE 5 Tutorial: