• Post Reply Bookmark Topic Watch Topic
  • New Topic
programming forums Java Mobile Certification Databases Caching Books Engineering Micro Controllers OS Languages Paradigms IDEs Build Tools Frameworks Application Servers Open Source This Site Careers Other Pie Elite all forums
this forum made possible by our volunteer staff, including ...
Marshals:
  • Campbell Ritchie
  • Tim Cooke
  • Liutauras Vilda
  • Jeanne Boyarsky
  • paul wheaton
Sheriffs:
  • Ron McLeod
  • Devaka Cooray
  • Henry Wong
Saloon Keepers:
  • Tim Holloway
  • Stephan van Hulst
  • Carey Brown
  • Tim Moores
  • Mikalai Zaikin
Bartenders:
  • Frits Walraven

What is scope of JTA transaction

 
Ranch Hand
Posts: 111
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • 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.
 
Bartender
Posts: 10336
Hibernate Eclipse IDE Java
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • 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
    Number of slices to send:
    Optional 'thank-you' note:
  • 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?
 
Greenhorn
Posts: 4
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • 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.
 
I can't take it! You are too smart for me! Here is the tiny ad:
Gift giving made easy with the permaculture playing cards
https://coderanch.com/t/777758/Gift-giving-easy-permaculture-playing
reply
    Bookmark Topic Watch Topic
  • New Topic