-->
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.  [ 6 posts ] 
Author Message
 Post subject: Does rollback undo in-memory changes after an Exception?
PostPosted: Tue Dec 09, 2003 5:03 pm 
Beginner
Beginner

Joined: Tue Nov 18, 2003 12:34 am
Posts: 39
Location: Dallas, Texas, US
Hi,
With regards to exception handling:

I make a few in-memory changes in an entity. Then, I do a save() for the first time and it errors out, for some reason. Now, if I roll back the transaction, I believe that Hibernate will try to undo the changes in the database. Since this is the first time I am doing a save() there has been no change in the database. Will Hibernate undo the in-memory changes as well using the getter/setter? Or Should I need to undo the in-memory changes?

Thank you very much.
Madhan.


Top
 Profile  
 
 Post subject:
PostPosted: Tue Dec 09, 2003 5:21 pm 
Beginner
Beginner

Joined: Tue Nov 18, 2003 12:34 am
Posts: 39
Location: Dallas, Texas, US
Just a clarification. I am using JDBCTransactions...


Top
 Profile  
 
 Post subject:
PostPosted: Tue Dec 09, 2003 6:20 pm 
Hibernate Team
Hibernate Team

Joined: Tue Aug 26, 2003 7:19 pm
Posts: 2364
Location: Brisbane, Australia
If an exception is thrown or rollback then you should throw away the session object or clear the cache. This addresses the in memory state.


Top
 Profile  
 
 Post subject:
PostPosted: Tue Dec 09, 2003 6:23 pm 
Beginner
Beginner

Joined: Tue Nov 18, 2003 12:34 am
Posts: 39
Location: Dallas, Texas, US
By clear cache, do you mean "refresh()" so that the state of the object can be re-read?
Thanks,
Madhan.


Top
 Profile  
 
 Post subject:
PostPosted: Tue Dec 09, 2003 8:01 pm 
Hibernate Team
Hibernate Team

Joined: Tue Aug 26, 2003 12:50 pm
Posts: 5130
Location: Melbourne, Australia
Quote:
Will Hibernate undo the in-memory changes as well using the getter/setter?


No, it does not. However, I consider adding an option for this in a future version of Hibernate.


Top
 Profile  
 
 Post subject:
PostPosted: Wed Dec 10, 2003 11:03 am 
Hibernate Team
Hibernate Team

Joined: Tue Aug 26, 2003 7:19 pm
Posts: 2364
Location: Brisbane, Australia
trmm333 wrote:
By clear cache, do you mean "refresh()" so that the state of the object can be re-read?
Thanks,
Madhan.


No I mean session.clear().


Top
 Profile  
 
Display posts from previous:  Sort by  
Forum locked This topic is locked, you cannot edit posts or make further replies.  [ 6 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.