• Post Reply Bookmark Topic Watch Topic
  • New Topic

Dooming a transaction

 
Aaron Raja
Ranch Hand
Posts: 206
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Why dooming a transaction? can you tell me at what kind of senerio we use this ?
 
Paul Sturrock
Bartender
Posts: 10336
Eclipse IDE Hibernate Java
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
"dooming" a transaction is not a term I've come accross. Where did you hear it? Are you talking about calling setRollbackOnly() after an application exception?
[ June 08, 2007: Message edited by: Paul Sturrock ]
 
Aaron Raja
Ranch Hand
Posts: 206
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
yes I mean ejbContext.setRollbackOnly();

this call will force transaction to rollback but how it is used in the method below get me confusion

public void fireSettlementCalculation() throws Exception {
if ( ejbContext.getRollbackOnly() ) {
// transaction is doomed so return doing nothing
return;
}
else {
performSettlementCalculation();
}
}

In this if condition if is quilify to be true transaction is doomed already so return doing nothing if not do performSettlement Calculation, can we use this (ejbContext.getRollbackOnly() ) in if statement and if it is then senerio please to explain better way?
I am maintaing the code written by some interesting and so called smart EJB dude!!!
 
Paul Sturrock
Bartender
Posts: 10336
Eclipse IDE Hibernate Java
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
The purpose of getRollbackOnly() is to short cut failure. If you have a long transaction and something fails right at the start there is little point going through the extra processing only to roll back. Is it required? Not really.
 
Aaron Raja
Ranch Hand
Posts: 206
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Thanks now it is clear to me! You made my day!!!
 
  • Post Reply Bookmark Topic Watch Topic
  • New Topic
Boost this thread!