Win a copy of 97 Things Every Java Programmer Should Know this week in the Java in General 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
  • Paul Clapham
  • Jeanne Boyarsky
  • Junilu Lacar
  • Henry Wong
Sheriffs:
  • Ron McLeod
  • Devaka Cooray
  • Tim Cooke
Saloon Keepers:
  • Tim Moores
  • Stephan van Hulst
  • Frits Walraven
  • Tim Holloway
  • Carey Brown
Bartenders:
  • Piet Souris
  • salvin francis
  • fred rosenberger

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
 
I don't always make ads but when I do they're tiny
Devious Experiments for a Truly Passive Greenhouse!
https://www.kickstarter.com/projects/paulwheaton/greenhouse-1
    Bookmark Topic Watch Topic
  • New Topic