Paul Anilprem wrote:
Ramy Diab wrote:Hello All,
I need to know until which point exactly the extended persistence context is exist ?
Is it exist until the EntityManager instance is closed , or until all transactions invoked by the EntityManager ?
Thanks in advance
As per Section 7.7 of JPA 2.0 specification:
The extended persistence context exists from the point at which the entity manager has been created
using EntityManagerFactory.createEntityManager until the entity manager is closed by means of EntityManager.close.
You should go through chapter 7 of the specification. It will solve all your doubts.
HTH,
Paul.
This is true for application-managed persistence context, but for container-managed persistence context (section 7.6. in specification), i quote:
"A container-managed extended persistence context can only be initiated within the scope of a stateful
session bean. It exists from the point at which the stateful session bean that declares a dependency on an
entity manager of type PersistenceContextType.EXTENDED is created, and is said to be bound
to the stateful session bean. The dependency on the extended persistence context is declared by means
of the PersistenceContext annotation or persistence-context-ref deployment descrip-
tor element.
The persistence context is closed by the container when the @Remove method of the stateful session
bean completes (or the stateful session bean instance is otherwise destroyed)."
?