• 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
  • Devaka Cooray
  • Ron McLeod
  • Jeanne Boyarsky
Sheriffs:
  • Liutauras Vilda
  • paul wheaton
  • Junilu Lacar
Saloon Keepers:
  • Tim Moores
  • Stephan van Hulst
  • Piet Souris
  • Carey Brown
  • Tim Holloway
Bartenders:
  • Martijn Verburg
  • Frits Walraven
  • Himai Minh

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

 
Greenhorn
Posts: 3
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • 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.
 
Ranch Hand
Posts: 134
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • 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.
 
Today's lesson is that you can't wear a jetpack AND a cape. I should have read this tiny ad:
the value of filler advertising in 2021
https://coderanch.com/t/730886/filler-advertising
reply
    Bookmark Topic Watch Topic
  • New Topic