-->
These old forums are deprecated now and set to read-only. We are waiting for you on our new forums!
More modern, Discourse-based and with GitHub/Google/Twitter authentication built-in.

All times are UTC - 5 hours [ DST ]



Forum locked This topic is locked, you cannot edit posts or make further replies.  [ 1 post ] 
Author Message
 Post subject: Transaction Not Rolling Back
PostPosted: Mon Aug 28, 2006 10:22 pm 
Newbie

Joined: Thu Aug 03, 2006 6:54 pm
Posts: 16
If anyone has a working example of a transaction rolling back properly could they please let me know.

I only need rollback to work for one transaction updating one database. All the examples on the web and in the Hibernate Documentation seem to follow this basic pattern:

Code:
Session sess = factory.openSession();
Transaction tx = null;
try {
tx = sess.beginTransaction();
// do some work
...
tx.commit();
}
catch (RuntimeException e) {
if (tx != null) tx.rollback();
throw e; // or display error message
}
finally {
sess.close();
}


I have tried these out and it doesnt seem to work for me. The way I am currently testing the rollback is by having an update that fails because of a foreign key association failed. However, frustratingly, the update is not being rolled back. The entry is still being made in the database and an exception is thrown.

Any help in this matter would be greatly appreciated.

Outlaw.


Top
 Profile  
 
Display posts from previous:  Sort by  
Forum locked This topic is locked, you cannot edit posts or make further replies.  [ 1 post ] 

All times are UTC - 5 hours [ DST ]


You cannot post new topics in this forum
You cannot reply to topics in this forum
You cannot edit your posts in this forum
You cannot delete your posts in this forum

Search for:
© Copyright 2014, Red Hat Inc. All rights reserved. JBoss and Hibernate are registered trademarks and servicemarks of Red Hat, Inc.