I have parent/child relationship, and child have composite id
Parent
<id name="Id" type="Int32">
<generator class="identity" />
</id>
<set name="Children" table="CTable" cascade="all-delete-orphan" inverse="true" lazy="false" >
<key column="ParentId"/>
<one-to-many class="ChildrenClass"/>
</set>
Child
<composite-id unsaved-value="none">
<key-property name="ParentId"/>
<key-property name="ChildId"/>
</composite-id>
What I want: 1) Get Parent from the DB, close the session, pass Parent from service to client 2) When Parent is back from client, save it and all its children in the DB, in a new session
In step 2, I call var merged = Session.Merge(product);
I use Merge() because it seems the only way to make NHib handle added/deleted elements in children collection.. BUT nHibernate reset all id-s in newly added children, so I have new children with ParentId == 0 and ChildId == 0. So the question is - how to tell NHibernate to keep ids from entity that is passed in Merge()?.. Please help.