I have a problem. I am using JSF1.1, EJB2.x, JDBC and weblogic8.1sp6. the structure of the application is like this, jsf bean calls facade bean(which is stateless session bean) method. facade bean method calls dao method to perform database insert/updates. the trasaction attribute of facadebean's method is set to required in ejb-jar.xml. now I create connection in the dao method and pass that to further dao methods. I have connection.setAutoCommit(false) in the dao methods. Problem is that in case of exception, rollback is not working. whatever updates are performed before the exception, get commited to the database, whether I specify rollback in the catch block or not. If I rollback in the dao method, I get the following exception when trying to rollback. can anyone help me please?
Originally posted by Nitin Deshmukh: hi, found out that setRollBackOnly() is a method of EJBContext. used and tested this method in a dummy method and it seems to work. thanks a lot for the response.
Yes indeed, it is called on the EJBContext. This is one of the cornerstones of EJB CMT. An EJB method that is running in a container managed transaction needs to know when an exception == a transaction rollback. It is perfectly possible for your method to handle a situation where you encounter an exception and you want the transaction to be committed anyway. So you need to tell the container that it should rollback via setRollbackOnly().