I did some tracing in the NHibernate Code. The exception is caused by the CheckUniqueness method in StatefulPersistenceContext class. When it enters the GetEntity method the line entitiesByKey.TryGetValue(key, out result); returns a result which later causes the exception.
It checks before whether the entity is detached and calls in DefaultUpdateEventListener class Method PerformSaveOrUpdate the EntityIsDetached Method Any idea? Thank you so much antoschka On 4 Mrz., 02:32, antoschka <[email protected]> wrote: > having tried several thinks, I would like to depict my actual problem, > so you understand where I'am stuck > > I have 2 entities which relate to each other 1:n. > The mapping contains one-to-many bag. > > Now I like to do the following > EntityA (parent) is ralted to two EntityB (children). > - in the current session I like to evict one of the EntityB > - change one of the attributes of entityB > - Add a new entityB to entityA > - reassociate the changed entityB to the session > - and save EntityA > > Actually the last two step give me a headach. If i manage to > reassociate it the saving fails saying "a different object with the > same > identifier value was already associated with the session" > If I do not reassociate it the saving works fine but the changes of > the detached Entity B will not be transfered to the DB. > > Got you help me a little to solve the problem? > > Thanks for your help > > antoschka --~--~---------~--~----~------------~-------~--~----~ You received this message because you are subscribed to the Google Groups "nhusers" group. To post to this group, send email to [email protected] To unsubscribe from this group, send email to [email protected] For more options, visit this group at http://groups.google.com/group/nhusers?hl=en -~----------~----~----~----~------~----~------~--~---
