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 Using Application Managed Entity Manager for Bean with CMT 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 "Using Application Managed Entity Manager for Bean with CMT" Watch "Using Application Managed Entity Manager for Bean with CMT" New topic
Author

Using Application Managed Entity Manager for Bean with CMT

Juggy Obhi
Ranch Hand

Joined: Jul 02, 2007
Posts: 51
Hi All,

I was going through Enthuware Trial Version. There was one question regarding the usage of Container Managed Entity Manager for BMT. It is Allowed.

I want to know can we use Application Managed Entity Manager for CMT?


It does not matter how many times you fall,what matters is how many times you stand back.
Satya Maheshwari
Ranch Hand

Joined: Jan 01, 2007
Posts: 368
Quoting from Apress Pro EJB 3:

Like container-managed persistence contexts, application-managed persistence contexts may be synchronized with JTA transactions. Synchronizing the persistence context with the transaction means that a flush will occur if the transaction commits, but the persistence context will not be considered associated by any container-managed entity managers. There is no limit to the number of application-managed persistence contexts that may be synchronized with a transaction, but only one container-managed persistence context will ever be associated. This is one of the most important differences between application-managed and container-managed
entity managers.
An application-managed entity manager participates in a JTA transaction in one of two ways. If the persistence context is created inside the transaction, then the persistence provider will automatically synchronize the persistence context with the transaction. If the persistence context was created earlier (outside of a transaction or in a transaction that has since ended), the persistence context may be manually synchronized with the transaction by calling joinTransaction() on the EntityManager interface. Once synchronized, the persistence context will automatically be flushed when the transaction commits.

[ September 27, 2008: Message edited by: Satya Maheshwari ]

Thanks and Regards
Juggy Obhi
Ranch Hand

Joined: Jul 02, 2007
Posts: 51
I haven't worked hard on persistance part of the EJB. I will go through it again. All i could understand from this is that It is possible
Juggy Obhi
Ranch Hand

Joined: Jul 02, 2007
Posts: 51
Hi Satya,

After your quote i gave a thorough study to the EJB Persistence Spec. Now each and every statement you mentioned is crystal clear to me.

Thanks
 
I agree. Here's the link: http://aspose.com/file-tools
 
subject: Using Application Managed Entity Manager for Bean with CMT
 
Similar Threads
Entity Managers - Types
Doubt on PersistenceContext
Can I say an entity manager injected into session bean must be container managed?
Difference between container managed entity manager & CMT
Use transaction with add/update and delete?