Win a copy of Modern JavaScript for the Impatient this week in the Server-Side JavaScript and NodeJS forum!
  • 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 all forums
this forum made possible by our volunteer staff, including ...
Marshals:
  • Campbell Ritchie
  • Ron McLeod
  • Paul Clapham
  • Bear Bibeault
  • Junilu Lacar
Sheriffs:
  • Jeanne Boyarsky
  • Tim Cooke
  • Henry Wong
Saloon Keepers:
  • Tim Moores
  • Stephan van Hulst
  • Tim Holloway
  • salvin francis
  • Frits Walraven
Bartenders:
  • Scott Selikoff
  • Piet Souris
  • Carey Brown

UserTransaction and EntityTransaction

 
Ranch Hand
Posts: 40
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
UserTransction manages JTA transactions while EntityTransction is responsible foir resource-local transactions.
What if this happens:
ut.begin();
et=em.getEntityTransaction();
et.begin(); // what happens here? an IllegalStateException? Or the outer transaction is suspended?
...
 
Ranch Hand
Posts: 413
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Im not 100% sure. But I think this is illegal. Because nested transactions not allowed.
 
Ranch Hand
Posts: 342
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
That shouldn't be a problem: JTA transactions and entity transactions don't influence each other (see core spec. 13.3.3, footnote 63).
[ November 21, 2008: Message edited by: Ralph Jaus ]
 
Chaminda Amarasinghe
Ranch Hand
Posts: 413
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
JTA Transactions and User Transactions :roll: User Transactions are also JTA Transactions.
 
Ralph Jaus
Ranch Hand
Posts: 342
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Yeah In the first version I had writen "JTA transactions and user transactions" instead of "JTA transactions and entity transactions". I corrected the mistake as fast as I could, but no chance, Chaminda was faster
 
Chaminda Amarasinghe
Ranch Hand
Posts: 413
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Its ok Ralph....

But problem is still remaining. the section you pointed was not much helpful

Do you think this is possible?
 
Ralph Jaus
Ranch Hand
Posts: 342
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Hi Cham,

Do you think this is possible?

Yes, see for example Pro EJB 3 chapter 5, page 130:

Resource transactions [= entity transactions, remark from me] may be freely started and committed any number of times within a JTA transaction without impacting the state of the JTA transactions.

This can be used for example to decouple persisting log entries from committing resp. rolling back the business transactions.

I also tried this example with starting and committing an entity transaction within a JTA transaction that will be rolled back. Worked as expected: The business data were not in the database while the log entries are.
 
Chaminda Amarasinghe
Ranch Hand
Posts: 413
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Thanks Ralph for the infor
 
To get a wish, you need a genie. To get a genie, you need a lamp. To get a lamp, you need a tiny ad:
Building a Better World in your Backyard by Paul Wheaton and Shawn Klassen-Koop
https://coderanch.com/wiki/718759/books/Building-World-Backyard-Paul-Wheaton
    Bookmark Topic Watch Topic
  • New Topic