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

Call 2 trx one - with RollBack option for 1st.

 
Dhir Virat
Greenhorn
Posts: 3
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Hi,
How should we combine two transactions into 1 call and yet make the Transaction Rollback savvy. Let me represent with a scenrio logically
MySessionBean
{
methodA() - trx attribute ( REQUIRED / NEW )
methodB() - trx attribute ( NEW )
}
Here is what the intention is:
If MethodA Fails - RollBack
If MethodA Success - method B Fails - RollBack Trx for A two.

There is reason for not a combining the calls to method B and method A. Otherwise teh Roolback Issue would have been simpler.
Any Reference - material where the detailed explaintion of such/similar cases will high be appretiated.
 
Sujatha Kumar
Ranch Hand
Posts: 134
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Hi Dhir,
If Method A fails by throwing a exception it will never execute Method B.
The commit statement for the both transactions should be executed only after the successful method call.
Illustration
=============
try
{
call methodA();
call methodB();
commit Tran1;
commit Tran2;
}
catch(Exception e)
{
throw e;
}
Hope it helps.
 
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic