Re: Issues in calling DAO from Sateless session bean
Milind Patil <[email protected]> Fri, 17 Dec 2004 11:08:28 +0530
| Newsgroups | gmane.comp.java.sun.ejb.general |
|---|---|
| Message-ID | <OF0A261585.AA1CE547-ON65256F6D.005F9BD7-65256F6D.0060E434@tcs.com> |
Hi, Even though bean uses container managed transactions, container knows only EJBException. It catches only EJBException and in that case it automatically marked particular transaction for rollback. But if your application is throwing a non-EJBException then container is not able to catch that exception and it just throw it. In order to rollback transaction, call rollback methd and set rollback flag as true then wrap application exception in EJBException and just throw it. Afterwards it altogether container's responsibility to mark this transaction for rollback and send notification to transaction manager for rollback...and so on...... Hope this will help u to understand how container handles rollback automatically..... Milind Bhaskar Patil Tata Consultancy Services Limited Mailto: [email protected] Website: http://www.tcs.com Suresh Babu Koya <[email protected]> Sent by: A mailing list for Enterprise JavaBeans development <[email protected]> 16/12/2004 18:07 Please respond to [email protected] To [email protected] cc 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". ForwardSourceID:NT00002D9E Notice: The information contained in this e-mail message and/or attachments to it may contain confidential or privileged information. If you are not the intended recipient, any dissemination, use, review, distribution, printing or copying of the information contained in this e-mail message and/or attachments to it are strictly prohibited. If you have received this communication in error, please notify us by reply e-mail or telephone and immediately and permanently delete the message and any attachments. Thank you =========================================================================== 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".