Hello: I am new to nhibernate and having been having issues modelling a simple relationship of parent child. Parent table: parent_id [ Guid ] Child table: child_id[guid], parent_id [ FK from Parent Table, Not null, Guid ] Parent has a "list" of child objects [0...n]
The Parent Object references a HashedSet<Child>, however when I try to save
{"Cannot insert the value NULL into column 'parent_id', table 'tblChild'; column does not allow nulls. INSERT fails.\r\nThe statement has been terminated."}
I don't have any property in Child object referring the parent back, since the child shouldn't exist on its own.
Any pointers are much appreciated.
-------------snip----------------snip---------------snip----------------- <?xml version="1.0" encoding="utf-8"?> <hibernate-mapping xmlns="urn:nhibernate-mapping-2.2" namespace="mynamespace" assembly="mynamespace"> <class name="mynamespace.parent" table="tblParent"> <id name="ParentId column="parent_id"> <generator class="guid" /> </id> <set name="Children" table="tblChild" lazy="true"> <key column="parent_id" not-null="true" /> <one-to-many class="Child" /> </set> </class> <class name="mynamespace.Child" table="tblChild"> <id name="ChildId" column="child_id"> <generator class="guid" /> </id> <many-to-one name="ParentId" class="Parent" column="parent_id" not-null="true" /> </class> </hibernate-mapping> -----------------------------------------------------------------------------------------------
|