The problem with disposing of the NHibernate business object returned from the session and replacing it with a new one is that the business object returned by the session is actually an NHibernate proxy with special collections that remember what changes have been made. If I simply try and update NHibnerate with the copy when the user clicks "Save" NHibernate will attempt to insert all the objects in the child collection (I think?). I tried to ask this question earlier in the forum and I didn't get a response:
If I make a binary copy of an NHibernate proxy (via binary serialization), dereference the original, and call session.Save on the copy will the behaviour be the same as if I called session.Save on the NHibernate proxy?
In other words: Does the session store a pointer to the retrieved object in the cache or does it simply use the ID?
Thanks,
Jafar
|