• Post Reply
  • Bookmark Topic Watch Topic
  • New Topic

JoinTransaction

 
Nikhil Jain
Ranch Hand
Posts: 392
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Why do we call joinTransaction? Does'nt the transaction start after calling ut.begin() & ends ut.end()?
 
Nicolas Stern
Ranch Hand
Posts: 57
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
You are mixing the concepts of Transaction Boundaries (Container-managed or application-managed) and persistence context(which can be also container or application-managed).

UserTransaction.begin() and UserTransaction.commit() relates to Application-managed transaction boundaries.

EntityManager.joinTransaction() can be called when the entity manager instance has been created outside of an active transaction.

Have a look at the example 5.7.1.2 of the Persistence Specifications - it demonstrates exactly this situation.

HTH - Cheers
 
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic