In this chapter we examined EntityManager
services in more detail. Application-managed entity managers are provided by the JPA for Java applications which do do not require the services offered by an EJB 3 container but still require persistence. We provided an example of using an application-managed entity manager.
We discussed the concept of managed and detached entities and described a number of EntityManager
methods such as merge()
. We described cascade operations.
We covered the extended persistence context which enables a persistence context to span more than one transaction. An extended persistence context can only be used by stateful session beans.
We looked at entity lifecycle callback methods. These methods can be placed in the entity itself; an alternative is to place such methods in separate classes known as entity listeners.