Win a copy of Murach's Python Programming this week in the Jython/Python forum!
  • Post Reply Bookmark Topic Watch Topic
  • New Topic

dumb question about transactions  RSS feed

 
Shreyas Reddy
Ranch Hand
Posts: 49
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
What happens in the following scenario?

Method bar() of BMT bean1 starts transaction(tx A)
bar() calls method foo() on CMT bean2
foo() marks tx A for roll back by calling EJBContext.setRollbackOnly()
foo() returns
bar() calls commit() on tx A (suppose bar() didn't check if the tx was marked for rollback by foo())

Does bar() throw RollbackException or any other exception?
I hope the question made some sense.
Thanks,
 
Brian Tinnel
Ranch Hand
Posts: 69
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
When commit is called for a Transaction that has been marked for rollback, the transaction will be rolled back and then a RollbackException will be thrown. So, foo will throw a RollbackException. Also note that if an XA transaction is involved, you might get a HeuristicMixedException or HeuristicRollbackException instead of the RollbackException
 
  • Post Reply Bookmark Topic Watch Topic
  • New Topic
Boost this thread!