Hi,
I have the following mapping(I removed properties unrelated to this
problem)
<class name="EntityA" table="TableA" >
<id name="Id" column="Id" type="Int32" unsaved-value="null">
<generator class="native"/>
</id>
<one-to-one name="B" class="EntityB" cascade="all-delete-orphan" /
> <!-- B can be null-->
</class>
<class name="EntityB" table="TableB" >
<id name="Id" column="Id" type="Int32" unsaved-value="null">
<generator class="foreign">
<param name="property">A</param>
</generator>
</id>
<one-to-one name="A" constrained="true"/> <!-- A cannot be null-->
</class>
The problem is with the following scenario :
- in a session, I load myEntityA where myEntityA.B != null
- myEntityA is then detached from the session and handed to the UI of
the desktop application
- The user, using the UI, does myEntityA.B = null;
- Then he realises it was a mistake and creates a new EntityB
( myEntityA = new EntityB{ A = myEntityA}; )
- He then asks for myEntityA to be saved
- A new session is created and Session.SaveOrUpdateCopy(myEntityA)
is performed, which throws :
Nhibernate.NonUniqueObjectException: a different object with the
same identified value was already associated with the session
I'm not sure to understand why I get this error, I hoped
SaveOrUpdateCopy would merge the values from the newly created EntityB
to the one loaded from the database during the SaveOrUpdateCopy, but
it seems not to be the case.
Thanks in advance for your help,
Stephane.
--
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.