File APIs for Java Developers
Manipulate DOC, XLS, PPT, PDF and many others from your application.
The moose likes Object Relational Mapping and the fly likes exceptions on commit Big Moose Saloon
  Search | Java FAQ | Recent Topics | Flagged Topics | Hot Topics | Zero Replies
Register / Login
JavaRanch » Java Forums » Databases » Object Relational Mapping
Bookmark "exceptions on commit" Watch "exceptions on commit" New topic

exceptions on commit

Wendy Gibbons

Joined: Oct 21, 2008
Posts: 1107

if the commit throws an exception do you need to do a manual rollback to close the transaction

or will the rollback the commit does internally do that for me?
James Sutherland
Ranch Hand

Joined: Oct 01, 2007
Posts: 553
Commit will automatically rollback the database transaction if the commit fails.

You could is not quite right though, you should have a return or something after the rollback, otherwise you are trying to commit the transaction that was rolledback.
Normally the try/catch the commit is inside the try,


TopLink : EclipseLink : Book:Java Persistence : Blog:Java Persistence Performance
Wendy Gibbons

Joined: Oct 21, 2008
Posts: 1107

thanks, i will update everything (not very big yet)
I agree. Here's the link:
subject: exceptions on commit
jQuery in Action, 3rd edition