I have two related tables:
Code:
<class name="Center" table="Center">
<id name="Id" column="CenterID" unsaved-value="0">
<generator class="identity" />
</id>
<property name="Name" type="String" length="25" not-null="true" />
<many-to-one name="Region" column="RegionID" class="Region"
not-null="true" />
</class>
Code:
<class name="Region" table="Region">
<id name="Id" type="Int32" column="RegionID" unsaved-value="0">
<generator class="identity" />
</id>
<property name="Name" type="String" not-null="true" />
<set name="Centers" inverse="true" lazy="true" cascade="all">
<key column="RegionID" />
<one-to-many class="Center" />
</set>
</class>
Why an error occurs when I call save() only once?
Code:
Center c = new Center();
c.Name = "ccc";
Region r = new Region();
r.Name = "rrr";
r.CreditCenters.Add(c);
session.Save(r);
Best regards,
Sergey