EJB: CMT Commit the transactions till exception raised
T. Sravan Kumar Reddy
posted 3 years ago
Request you help me on the below issue.
I am using Contaier managed beans in EJB, calling the DAO method from Session bean and executing the same. DAO method have internal iterations, to insert the data into Database.
My requirement is that, Interative transactions should be commited till exception raised in loop without using the commit() statement.
If i call the setRollbackOnly() method in the exception block, it is rollbacking total transaction.
If I understand correctly, you want one transaction per DB insertion. So put the iteration in your service method, and in your DAO you have a single insert with a transaction attribute of REQUIRES_NEW.