Meaningless Drivel is fun!*
The moose likes EJB Certification (SCBCD/OCPJBCD) and the fly likes JTA Transaction Mangement Big Moose Saloon
  Search | Java FAQ | Recent Topics | Flagged Topics | Hot Topics | Zero Replies
Register / Login


Win a copy of Android Security Essentials Live Lessons this week in the Android forum!
JavaRanch » Java Forums » Certification » EJB Certification (SCBCD/OCPJBCD)
Bookmark "JTA Transaction Mangement" Watch "JTA Transaction Mangement" New topic
Author

JTA Transaction Mangement

Joe Harry
Ranch Hand

Joined: Sep 26, 2006
Posts: 9345
    
    2

Guys,

In terms of the JTA, what is the significant difference between a Transaction synchronization and Transaction association? Both to me sems lile associating a PersistenceContext with an active transaction. Did I get this right?


SCJP 1.4, SCWCD 1.4 - Hints for you, Certified Scrum Master
Did a rm -R / to find out that I lost my entire Linux installation!
Ralph Jaus
Ranch Hand

Joined: Apr 27, 2008
Posts: 342
Transaction synchronization means that the entity manager registers at the JTA transaction and will be informed from the transaction when a commit or rollback occurs. Every entity manager type (container-managed as well as application-managed) and any number of entity managers can be synchronized with the transaction.

Transaction Association has to do with sharing a persistence context and affects only container-managed entity managers: The first container-managed entity manager em1 those methods are called within a JTA transaction associates its persistence context with this transaction. If a method of a second container-managed entity manager em2 is called within the same transaction afterwards, em2 realizes that there is alreday an persistence context associated with the transaction. Therefore em2 won't create a new persistence context but uses the one from em1 instead. So em1 and em2 share the same persistence context. At most one persistence context can be associated with a JTA transaction.


SCJP 5 (98%) - SCBCD 5 (98%)
Joe Harry
Ranch Hand

Joined: Sep 26, 2006
Posts: 9345
    
    2

That sounds reasonable. Thanks!
nitin pokhriyal
Ranch Hand

Joined: May 19, 2005
Posts: 263
"The first container-managed entity manager em1 those methods are called within a JTA transaction associates its persistence context with this transaction. If a method of a second container-managed entity manager em2 is called within the same transaction afterwards, em2 realizes that there is alreday an persistence context associated with the transaction. Therefore em2 won't create a new persistence context but uses the one from em1 instead. So em1 and em2 share the same persistence context. At most one persistence context can be associated with a JTA transaction."

is it correct to say if persistent context will be propagated to another method only if the persistenceContext name are same because what if both the method have different context.
Krzysztof Koziol
Ranch Hand

Joined: Nov 19, 2006
Posts: 133

nitin pokhriyal wrote:
is it correct to say if persistent context will be propagated to another method only if the persistenceContext name are same because what if both the method have different context.


You mean the persistence unit name, right?


SCJP 5.0, SCWCD 5.0, SCBCD 5.0, SCEA/OCMJEA 5.0
nitin pokhriyal
Ranch Hand

Joined: May 19, 2005
Posts: 263
no i mean by persistence context as i was quoting ralph's comment.
 
I agree. Here's the link: http://aspose.com/file-tools
 
subject: JTA Transaction Mangement
 
Similar Threads
JDBC - 1.5 Transaction ?
Weblogic - EJB 2.0 CMR Relationship eager loading ??
what are differences between UserTransaction and EntityTransaction ?
BMT inside BMP
javax.persistence. TransactionRequiredException