This week's giveaway is in the Android forum.
We're giving away four copies of Android Security Essentials Live Lessons and have Godfrey Nolan on-line!
See this thread for details.
The moose likes EJB Certification (SCBCD/OCPJBCD) and the fly likes transaction rollback Big Moose Saloon
  Search | Java FAQ | Recent Topics | Flagged Topics | Hot Topics | Zero Replies
Register / Login


Win a copy of Android Security Essentials Live Lessons this week in the Android forum!
JavaRanch » Java Forums » Certification » EJB Certification (SCBCD/OCPJBCD)
Bookmark "transaction rollback " Watch "transaction rollback " New topic
Author

transaction rollback

Carlos Llona
Greenhorn

Joined: Apr 09, 2004
Posts: 15
Hello:

I have this doubt about roll back transaction;

If I have a method in a bean (MDB or session) with CMT, If the method throws a system Exception the transaction is automaticaly rolled back. (Supose that the method have a transaction)

But what happend if I have that bean with BMT, If the method throws a system exception the transaction is rolled back automaticaly or I have to rolled back???

Chauuu!!
Alex Sharkoff
Ranch Hand

Joined: Apr 11, 2004
Posts: 209
Carlos,

I'd say that it is a responsibility of a Bean Provider to make sure that the trnx is rolledback when the bean throws sys exception.

When using BMT all transaction management is up to the Bean Provider and the transaction rollback / commit is one of these responsibilities.




Alex (SCJP 1.4, SCBCD 1.3, SCWCD 1.4, SCJD 1.4)
Carlos Llona
Greenhorn

Joined: Apr 09, 2004
Posts: 15
thanks alex.

but, I think that this is a bad tecnique/practice because I would cach all exception (java.lang.Exception) in my method to rolledback the transaction, and every one knows that this is a very bad practice.

What do you think about that?
mini mehta
Ranch Hand

Joined: Oct 22, 2000
Posts: 120
According to the spec page 374

The Container catches a non-application exception; logs it (which can result in alerting the System
Administrator); and, unless the bean is a message-driven bean, throws the java.rmi.RemoteException
(or subclass thereof) to the client if the client is a remote client, or throws the
javax.ejb.EJBException (or subclass thereof) to the client if the client is a local client. The
Bean Provider can rely on the Container to perform the following tasks when catching a non-application
exception:
� The transaction in which the bean method participated will be rolled back.
� No other method will be invoked on an instance that threw a non-application exception.
This means that the Bean Provider does not have to perform any cleanup actions before throwing a
non-application exception. It is the Container that is responsible for the cleanup.

[ July 01, 2004: Message edited by: mini mehta ]
Alex Sharkoff
Ranch Hand

Joined: Apr 11, 2004
Posts: 209
Thanks Mini.

Sorry Carlos, my guess was wrong. Mini's post proved that the Bean Provider does not have to rollback the transaction in BMT beans when system exception is thrown. It makes Bean Provider's life just a little bit easier



[ July 01, 2004: Message edited by: Alex Sharkoff ]
 
I agree. Here's the link: http://aspose.com/file-tools
 
subject: transaction rollback
 
Similar Threads
Rollback
transaction doubt
More on Exceptions !
Query about MDB throwing application exception
Enthuware Explanation Doubt-23