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: Object version not rolled back on error?
PostPosted: Mon Nov 07, 2005 8:16 am 
Newbie

Joined: Sat Sep 17, 2005 12:48 am
Posts: 4
Hi,

In using the versioning feature (i.e. the <version> tag in the mapping for a class), when an object is updated, NHibernate checks to see if the version of the object matches the version of the corresponding row in the database before updatig - to ensure no updates to the data row occured since it was last read. If the versions match the object's version (and hence the underlying data row version) is updated and it is saved to the database.

However if an error occurs during a transactional update and I rollback the NHibernate transaction, the version of the data row in the database is rolledback, but the version inside the object is not rolled back. So when I use the same object at a later stage to perform an update, NHibernate gives me a StaleObjectStateException because the version of the object is more recent than the version of it's corresponding row in the database.

Is this a bug? Am I missing something?

Thanks.


Top
 Profile  
 
 Post subject:
PostPosted: Mon Nov 07, 2005 10:29 am 
Contributor
Contributor

Joined: Wed May 11, 2005 4:59 pm
Posts: 1766
Location: Prague, Czech Republic
NHibernate does not roll back any changes to objects. You are supposed to do it yourself, or usually you can just throw the object away and load a fresh one from the database.


Top
 Profile  
 
 Post subject:
PostPosted: Tue Nov 08, 2005 9:46 am 
Contributor
Contributor

Joined: Thu May 12, 2005 9:45 am
Posts: 593
Location: nhibernate.org
Can you create a JIRA issue for this problem?
We will see what we can do...

_________________
Pierre Henri Kuaté.
Get NHibernate in Action Now!


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.