In this chapter we will take a more detailed look at the entity manager. In particular we will cover:
Application-managed entity manager
Container-managed entity manager
Entity manager methods
Cascade operations
Extended persistence context
Entity lifecycle callback methods
Entity listener classes
We have already seen examples of the entity manager in previous chapters. All these examples made use of container-managed entity managers, where an entity manager's lifecycle is managed by the EJB 3 container. To allow for situations where we do not require the services offered by an EJB 3 container but would like to use the persistence model, the Java Persistence API provides application-managed entity managers. We will first take a look at application-managed entity managers, before returning to entity manager topics which apply irrespective of whether an entity manager is container-managed or application-managed.