• Post Reply Bookmark Topic Watch Topic
  • New Topic

What is scope of JTA transaction  RSS feed

 
Vish Shukla
Ranch Hand
Posts: 111
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Hi all,

I am going through Mikalai Zaikin's guide for SCBCD preparation. I just came across a statement that says,
When a JTA application-manager entity manager is used, if the entity manager is created outside the scope of the current JTA transaction, it is the responsibility of the application to associate the entity manager with the transaction by calling EntityManager.joinTransaction.
.

In this statement, I dont exactly understand what is the "scope of the current JTA transaction". It would be great if someone can explain this with example.
 
Paul Sturrock
Bartender
Posts: 10336
Eclipse IDE Hibernate Java
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
There is not much to explain really. Do you understand what JTA is?
 
Vish Shukla
Ranch Hand
Posts: 111
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
What I understand is using JTA transaction type, we can manage transactions which may include multiple resource managers, which may be in different VMs. So I guess this statement means that if current JTA transaction is created in some other VM, then this new resource manager needs to join that active transaction. Is this understanding correct?
 
seb tetris
Greenhorn
Posts: 4
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Vish Shukla wrote:Hi all,

I am going through Mikalai Zaikin's guide for SCBCD preparation. I just came across a statement that says,
When a JTA application-manager entity manager is used, if the entity manager is created outside the scope of the current JTA transaction, it is the responsibility of the application to associate the entity manager with the transaction by calling EntityManager.joinTransaction.
.

In this statement, I dont exactly understand what is the "scope of the current JTA transaction". It would be great if someone can explain this with example.


As an example : Suppose In a statefull session bean with bean managed trannsactions, the entity manager is created in a @PostConstruct method, with the EntityManagerFactor.createntitymanager.
So this entitymanager is created outside a JTA transaction.

A business method can now start a UserTransaction. The entitymanager is not associated with that transaction, and you will have to call joinTransaction.
when the business method ends you can commit the transaction.
 
  • Post Reply Bookmark Topic Watch Topic
  • New Topic
Boost this thread!