You have to throw EJBException when the operation fails. In a container managed transaction, commit and rollback are to be carried out by the contained and you application has to inform the container that the transaction has to be rolled back. For that you can use the setRollbackOnly method.
Hope this clarifies. Jaise -----Original Message----- From: A mailing list for Enterprise JavaBeans development [mailto:[EMAIL PROTECTED] On Behalf Of Suresh Babu Koya Sent: Thursday, December 16, 2004 6:42 PM To: [EMAIL PROTECTED] Subject: Re: Issues in calling DAO from Sateless session bean It was a Non system exception. It was an application exception extending Exception class. I got it now. Thanks, Koya Suresh Babu >>-----Original Message----- >>From: A mailing list for Enterprise JavaBeans development >>[mailto:[EMAIL PROTECTED] Behalf Of KR Kumar >>Sent: Thursday, December 16, 2004 6:19 PM >>To: [EMAIL PROTECTED] >>Subject: Re: Issues in calling DAO from Sateless session bean >> >> >>The exception thrown is runtime or application (user defined exception >>or any sub class of exception class)? >> >>EJB container rollbacks transaction only if its system exception. Check >>what kind of exception you are throwing. >> >>Hope this helps >> >>KR Kumar >> >>-----Original Message----- >>From: A mailing list for Enterprise JavaBeans development >>[mailto:[EMAIL PROTECTED] On Behalf Of Suresh Babu Koya >>Sent: Thursday, December 16, 2004 6:07 PM >>To: [EMAIL PROTECTED] >>Subject: Issues in calling DAO from Sateless session bean >> >>I have a stateless session bean which uses container managed >>transactions. I >>had to call >>a DAO in which I insert two records, from the session bean. If there is >>an >>exception while inserting >>second record in the DAO, I am facing the problem that the first record >>is >>already commited >>inspite of throwing the Exception. >> >>I was able to have a workaround by calling setRollbackonly on the >>transaction context. I am not sure >>why this should be done. If the transactions are managed by container >>and I >>am not calling commit >>explicitly why should I call setRollbackonly. >> >>Does anyone have any idea why this works this way? >> >>Regards, >>Koya Suresh >> >> >> >>====================================================================== == >>=== >>To unsubscribe, send email to [EMAIL PROTECTED] and include in the >>body >>of the message "signoff EJB-INTEREST". For general help, send email to >>[EMAIL PROTECTED] and include in the body of the message "help". >> >> >> >>DISCLAIMER: >>This message contains privileged and confidential information and >>is intended only for the individual named.If you are not the >>intended recipient you should not >>disseminate,distribute,store,print, copy or deliver this >>message.Please notify the sender immediately by e-mail if you >>have received this e-mail by mistake and delete this e-mail from >>your system.E-mail transmission cannot be guaranteed to be secure >>or error-free as information could be >>intercepted,corrupted,lost,destroyed,arrive late or incomplete or >>contain viruses.The sender therefore does not accept liability >>for any errors or omissions in the contents of this message which >>arise as a result of e-mail transmission. If verification is >>required please request a hard-copy version. >> >>================================================================== >>========= >>To unsubscribe, send email to [EMAIL PROTECTED] and include >>in the body >>of the message "signoff EJB-INTEREST". For general help, send email to >>[EMAIL PROTECTED] and include in the body of the message "help". >> ======================================================================== === To unsubscribe, send email to [EMAIL PROTECTED] and include in the body of the message "signoff EJB-INTEREST". For general help, send email to [EMAIL PROTECTED] and include in the body of the message "help". =========================================================================== To unsubscribe, send email to [EMAIL PROTECTED] and include in the body of the message "signoff EJB-INTEREST". For general help, send email to [EMAIL PROTECTED] and include in the body of the message "help".
