Exception Handling in EJB Transactions. 2004-02-24 - By Kalra, Ashwani
Back see below..
>-- --Original Message-- -- >From: Basava Rajesh [mailto:Basava.Rajesh@(protected)] >Sent: Tuesday, February 24, 2004 12:03 PM >To: J2EEPATTERNS-INTEREST@(protected) >Subject: Re: Exception Handling in EJB Transactions. > > >hi, > >thanks for the quick response. >Dont u think its a overhead in every method to catch the Application >Exception and do a setRollBackOnly() ?
Overhead is not there for catching, but for throwing exception. so dont worrry about that.
>This could be avoided by creating Application Exception extending the >EJBException and hence the container takes care of rolling back the >transactions. in this case you dont have the choice of retrying the transaction. Since its application exception, you can retry the Tx. But if you extend EJBException, it will become SystemException, and it will always be rolled back by container.
> >thanks n regards, >Rajesh > >-- --Original Message-- -- >From: Kalra, Ashwani [mailto:ashwani.kalra@(protected)] >Sent: Tuesday, February 24, 2004 11:45 AM >To: J2EEPATTERNS-INTEREST@(protected) >Subject: Re: Exception Handling in EJB Transactions. > > >Inline.... > >>-- --Original Message-- -- >>From: Basava Rajesh [mailto:Basava.Rajesh@(protected)] >>Sent: Tuesday, February 24, 2004 11:28 AM >>To: J2EEPATTERNS-INTEREST@(protected) >>Subject: Exception Handling in EJB Transactions. >> >> >>Hi, >> The EJB 2.0 specification states that if an >>EJBException is thrown, >>the container shall rollback the transaction while for >>Application level >>Exceptions, the container does not. But since EJBException is a >>RuntimeException(and thus is not checked), should the >>Application Exceptions >>thrown in the Data/Business layer extend EJBException?? > >They should be descendent of Exception classes > >>Or do >>we catch the >>Application Exceptions and do a manual context.setRollbackOnly(). >Yes , when ever in doubt of data integrity, do it. >> >> What would be the best way to handle rollback of >>Transactions when >>Application Exceptions are thrown? > >do context.setrollback or retry. then throw that exception to client if >could not succeed. > > >>TIA, >>Rajesh. >> >>==================================================================== >>Companion Site: http://www.corej2eepatterns.com >>J2EE BluePrints: http://java.sun.com/blueprints/corej2eepatterns >>List Archive: >>http://archives.java.sun.com/archives/j2eepatterns-interest.htm >l >Unsubscribing: email "signoff J2EEPATTERNS-INTEREST" to >listserv@(protected) > >__ ____ ____ ____ ____ ____ ____ ____ ____ ____ ____ >This message contains information that may be privileged or >confidential and >is the property of the Cap Gemini Ernst & Young Group. It is >intended only >for the person to whom it is addressed. If you are not the intended >recipient, you are not authorised to read, print, retain, >copy, disseminate, >distribute, or use this message or any part thereof. If you >receive this >message in error, please notify the sender immediately and >delete all copies >of this message. > >==================================================================== >Companion Site: http://www.corej2eepatterns.com >J2EE BluePrints: http://java.sun.com/blueprints/corej2eepatterns >List Archive: >http://archives.java.sun.com/archives/j2eepatterns-interest.html >Unsubscribing: email "signoff J2EEPATTERNS-INTEREST" to >listserv@(protected) > >==================================================================== >Companion Site: http://www.corej2eepatterns.com >J2EE BluePrints: http://java.sun.com/blueprints/corej2eepatterns >List Archive: >http://archives.java.sun.com/archives/j2eepatterns-interest.htm l Unsubscribing: email "signoff J2EEPATTERNS-INTEREST" to listserv@(protected)
__ ____ ____ ____ ____ ____ ____ ____ ____ ____ ____ This message contains information that may be privileged or confidential and is the property of the Cap Gemini Ernst & Young Group. It is intended only for the person to whom it is addressed. If you are not the intended recipient, you are not authorised to read, print, retain, copy, disseminate, distribute, or use this message or any part thereof. If you receive this message in error, please notify the sender immediately and delete all copies of this message.
==================================================================== Companion Site: http://www.corej2eepatterns.com J2EE BluePrints: http://java.sun.com/blueprints/corej2eepatterns List Archive: http://archives.java.sun.com/archives/j2eepatterns-interest.html Unsubscribing: email "signoff J2EEPATTERNS-INTEREST" to listserv@(protected)
|
|