• Post Reply
  • Bookmark Topic Watch Topic
  • New Topic

JTA Transaction Mangement

 
Joe Harry
Ranch Hand
Posts: 10124
3
Eclipse IDE Mac PPC Ubuntu
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
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?
 
Ralph Jaus
Ranch Hand
Posts: 342
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
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.
 
Joe Harry
Ranch Hand
Posts: 10124
3
Eclipse IDE Mac PPC Ubuntu
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
That sounds reasonable. Thanks!
 
nitin pokhriyal
Ranch Hand
Posts: 263
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
"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
Posts: 133
Eclipse IDE Java Spring
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
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?
 
nitin pokhriyal
Ranch Hand
Posts: 263
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
no i mean by persistence context as i was quoting ralph's comment.
 
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic