Ah, I see. I wasn’t aware of this limitation. Sure, I’m aware of the problems with inconsistency between cached objects (those in the session’s Identity Map, IM) and objects in the database. I fully understand that. But in the case where I first encountered this “what I thought was a bug” I knew that I only had one object in the session. I tried doing an Evict followed by a Get and I could for certain see that the object was fetched from the database again. And for sure, it was fetched with its persisted version number. Still, the following save uses not that version number but the prior version number. (This was also shown in the test routine that I supplied you with.) My conclusion is, if I dare, that NH stores the version number at a “side location” when first retrieving an object but fails to clear that when evicting the same object. A classical problem of redundancy?
So, sure, the rule is not to keep using the session object after an exception (stemming from NHibernate, I only can assume), but you have to agree that the scenario described above has somewhat of a bad smell to it.
Anyway, thank you for the quick answer. Now I know what to do. I actually already did that in the test but felt that killing the session was, well, overkill :-)
Regards, Ingo
|