-->
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.  [ 3 posts ] 
Author Message
 Post subject: commit following previous rollback
PostPosted: Thu Nov 04, 2004 8:00 am 
Newbie

Joined: Thu Nov 04, 2004 7:53 am
Posts: 3
Hibernate version: 2.1.6

Code between sessionFactory.openSession() and session.close():

tx.beginTransaction()

loop:
session.save()
session.flush()
session.clear()

throw exception

tx.rollback

tx.beginTransaction()

save logs to database

tx.commit()

Name and version of the database you are using:
Oracle 8i

Hi,

Hopefully the above pseudo code is clear enough. What I'm seeing is that after doing a bulk insert (with flush and clear every 30 saves to reduce memory usage), and before I commit, if an exception is thrown I roll back the previous updates. I then create a new transaction in order to save logs to the database and commit these. I then find that all the saves I made in the previous transaction, which I called rollback on, are now in the database.

Is there any way to avoid this situation? Do I need to recreate the session after the rollback in order to lose the previous flushes?

thanks,

Mark


Top
 Profile  
 
 Post subject: commit following previous rollback
PostPosted: Thu Nov 04, 2004 8:23 am 
Newbie

Joined: Thu Nov 04, 2004 7:53 am
Posts: 3
Hi,

resolved it almost immediately after posting my question. I was flushing every 30 records, but if there were records that had been saved and not flushed within that loop, when the next commit happened, the records that had not been flushed were now flushed.

I presume that means then that a rollback will only rollback anything that has been flushed within a session, and even in follow on transaction, the previous transaction's records will be committed?

Mark


Top
 Profile  
 
 Post subject:
PostPosted: Thu Nov 04, 2004 8:51 am 
Expert
Expert

Joined: Thu Jan 29, 2004 2:31 am
Posts: 362
Location: Switzerland, Bern
Are you reusing business objects from the first transaction in the second one? This would not work.

You can have a look at http://forum.hibernate.org/viewtopic.php?t=933495 to learn more about this (as I had too ;-) ).

HTH
Ernst


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

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.