Hi,
I'm new to nhibernate and I think I will heavily use it in the very near future. Now I'm playing with the examples. But I have a problem...
this is the code I use:
fiu(Romanian)=son(English)
mama(Romanian)=mother(English)
Code:
ClassLibrary1.Cat mama=new ClassLibrary1.Cat();
mama.Name="mama";
mama.Birthdate=DateTime.Now;
ClassLibrary1.Cat fiu1=new ClassLibrary1.Cat();
fiu1.Name="fiu1";
fiu1.Birthdate=DateTime.Now;
ClassLibrary1.Cat fiu2=new ClassLibrary1.Cat();
fiu2.Name="fiu2";
fiu2.Birthdate=DateTime.Now;
ClassLibrary1.Cat fiu3=new ClassLibrary1.Cat();
fiu3.Name="fiu3";
fiu3.Birthdate=DateTime.Now;
mama.Kittens=new Iesi.Collections.HashedSet();
mama.Kittens.Add(fiu1);
mama.Kittens.Add(fiu2);
mama.Kittens.Add(fiu3);
session.Save(mama);
Basically I want a cat with a few sons and when the mother is saved I want the mother_id from each son to be seted correctly. But this is not happening... :(( mother_id is NULL for every son
the mapping xml:
Code:
<?xml version="1.0" ?>
<hibernate-mapping xmlns="urn:nhibernate-mapping-2.0">
<class name="ClassLibrary1.Cat, ClassLibrary1, Version=1.0.0.0, Culture=neutral, PublicKeyToken=null" table="CATS">
<id name="Id" column="uid" type="Int64">
<generator class="identity"/>
</id>
<property name="Birthdate" type="Date"/>
<property name="Sex" not-null="true" update="false"/>
<property name="Weight"/>
<property name="Name"/>
<many-to-one name="Mate" column="mate_id"/>
<set name="Kittens" cascade="all">
<key column="mother_id"/>
<one-to-many class="ClassLibrary1.Cat, ClassLibrary1, Version=1.0.0.0, Culture=neutral, PublicKeyToken=null"/>
</set>
</class>
</hibernate-mapping>
What am I missing?