Win a copy of The Business Blockchain this week in the Cloud forum!
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic

UserTransaction and EntityTransaction

 
Tang Yue
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?
...
 
Chaminda Amarasinghe
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.
 
Ralph Jaus
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
 
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic