Re: managing transactions in EJB
Monday, March 21, 2005 05:08 AM
In EJB you have to first tell us what container are u using for EJB. Like in websphere you have to specify whether the transaction type is container-managed or application-managed.
If for container-managed u have to set the attributes 1.requires 2.requires new 3. mandatory 4. not supported 5. supported depending on ur requirement. And also in the end of the method which u want to rollback if any problem arises should be enclosed with the try catch
//place ur code or SQL Statements.
return new EjbException(e.getMessage())
This EJBException informs the container that the method has failed and it will rollback the transaction.
If u want to manage the transactions all by the application itself u have the transaction API's and u have to begin a transaction and end a transaction.