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.
|