This week's book giveaway is in the OO, Patterns, UML and Refactoring forum. We're giving away four copies of Refactoring for Software Design Smells: Managing Technical Debt and have Girish Suryanarayana, Ganesh Samarthyam & Tushar Sharma on-line! See this thread for details.
Can someone please explain why Container throws 2 different (EJBExceptiion and EJBTransactionRolledbackException) exceptions in case of System exception in bean(CMT) method upon the transaction context of caller?
ie, why container throws EJBExceptiion if TM creates a new transaction for bean, while throws an EJBTransactionRolledbackException if TM does not create new transaction for bean.
[ October 25, 2008: Message edited by: Chaminda Amarasinghe ] [ October 25, 2008: Message edited by: Chaminda Amarasinghe ]
Joined: May 17, 2006
After a bit deeper thinking about the concept behind this I could come up with answer for my own question. Please correct me if Im wrong
If callee shares callers transaction it is important to inform the caller that callee shared caller's transaction but cause by an exception, so sets the transactionRalledBack and throws EJBTransactionRolledbackException and on other hand it does not make sense seting transactionRalledBack or throwing EJBTransactionRolledbackException if callee does not share caller's transaction instead of throwing an EJBException.
EJBTransactionRolledbackException is thrown to inform the caller that his transaction has been rolled back. If the callee has a transaction of his own, the caller doesn't care about that, so an EJBException is thrown instead.