• Post Reply Bookmark Topic Watch Topic
  • New Topic
programming forums Java Mobile Certification Databases Caching Books Engineering Micro Controllers OS Languages Paradigms IDEs Build Tools Frameworks Application Servers Open Source This Site Careers Other Pie Elite all forums
this forum made possible by our volunteer staff, including ...
Marshals:
  • Campbell Ritchie
  • Jeanne Boyarsky
  • Ron McLeod
  • Paul Clapham
  • Liutauras Vilda
Sheriffs:
  • paul wheaton
  • Rob Spoor
  • Devaka Cooray
Saloon Keepers:
  • Stephan van Hulst
  • Tim Holloway
  • Carey Brown
  • Frits Walraven
  • Tim Moores
Bartenders:
  • Mikalai Zaikin

Question about extended persistence context

 
Ranch Hand
Posts: 115
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
Hello All,

I am preparing for JPA certification.

After studying the Pro JPA 2.0 book I also studied Enthuware exams.

There is some points I still need to understand.

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
 
Enthuware Software Support
Posts: 4810
52
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator

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.
 
Ramy Nady
Ranch Hand
Posts: 115
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
Thank you Paul for your support here and in Enthuware discuss forums.
 
Greenhorn
Posts: 22
1
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator

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)."

?
 
Creator of Enthuware JWS+ V6
Posts: 3411
320
Android Eclipse IDE Chrome
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator

This is true for application-managed persistence context, but for container-managed persistence context (section 7.6. in specification), i quote:


Correct!

or in short:

Container Managed - Extended - PersistenceContextType.EXTENDED
  • Created: 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
  • Destroyed: it is closed by the container when the @Remove method of the stateful session bean completes (or the stateful session bean instance is otherwise destroyed).


  • Application-managed - Extended - Persistence Contexts
  • Created: the extended persistence context exists from the point at which the entity manager has been created using EntityManagerFactory.createEntityManager
  • Destroyed: the entity manager is closed by means of EntityManager.close.
  • reply
      Bookmark Topic Watch Topic
    • New Topic