Figure 10.3. Transaction-scoped persistence contexts keep entities attached only within the boundaries of the
The lifespan of the extended EntityManager lasts across multiple transactions. An
extended-scoped EntityManager can only be used with stateful session beans and lasts
as long as the bean instance is alive. Therefore, in persistence contexts with extended
scope, how long entities remain managed has nothing to do with transaction boundaries.
Once attached, entities stay managed as long as the EntityManager instance is around.
As an example, for a stateful session bean, an EntityManager with extended scope will
keep managing all attached entities until the EntityManager is closed as the bean itself
is destroyed. As figure 10.4 shows, this means that unless explicitly detached through a
remove method to end the life of the stateful bean instance, entities attached to an exten-
ded persistence context will remain managed across multiple transactions.