File APIs for Java Developers
Manipulate DOC, XLS, PPT, PDF and many others from your application.
http://aspose.com/file-tools
The moose likes EJB Certification (SCBCD/OCPJBCD) and the fly likes Entity Manager and Persistence Context Big Moose Saloon
  Search | Java FAQ | Recent Topics | Flagged Topics | Hot Topics | Zero Replies
Register / Login


Win a copy of EJB 3 in Action this week in the EJB and other Java EE Technologies forum!
JavaRanch » Java Forums » Certification » EJB Certification (SCBCD/OCPJBCD)
Bookmark "Entity Manager and Persistence Context " Watch "Entity Manager and Persistence Context " New topic
Author

Entity Manager and Persistence Context

amit punekar
Ranch Hand

Joined: May 14, 2004
Posts: 507
Hello,
While going through the JPA Specs (Page 130) , I came across the statement below.


If there is a different persistence context already associated with the JTA transaction, the container throws the EJBException.


If this is the case and I am working with two different Entity Managers pointing to two different Databases , will such operation fail?
Consider a use case in which a session bean method is interacting with two databases (2 phase commit). In this case I would have two EntityManager references. As per the statement above doing so could fail so I am a bit confused about how to achieve this?

Hope I am putting my question correctly as I myself is confused after reading this statement.

Or does the spec say or trying to say - different persistence context but for same database.

Thanks,
Amit
 
wood burning stoves
 
subject: Entity Manager and Persistence Context
 
Similar Threads
Entity instance
General persistence forum?
Application managed EntityManagers with transactions.
JPA Refresh Query from EJB3 In Action
Passed SCBCD 5.0 :)