how to force nhibernate to set the foreign key of the child item?
- by npeBeg
i have a collection in the mapping:
<bag name="Values" cascade="all-delete-orphan" lazy="false" inverse="true">
<key column="[TemplateId]"/>
<one-to-many class="MyNamespace.Value, MyLib"/>
</bag>
the Value object has a foreign key [TemplateId]. both entities has their generator set to "identity".
when i call session.Save() for the parent Template object, the Value objects has their [TemplateId] (the foreign key) set to zero, so an SQL exception appears.
how do i forse nhibernate to set the FK value for the child items to the value of the inserted parent object?