Win a copy of Programmer's Guide to Java SE 8 Oracle Certified Associate (OCA) this week in the OCAJP forum!
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic

EJB: CMT Commit the transactions till exception raised

 
T. Sravan Kumar Reddy
Greenhorn
Posts: 1
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Hi,

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.


Regards,
Sravan
 
Dieter Quickfend
Bartender
Posts: 543
4
Java Netbeans IDE Redhat
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
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.
 
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic