Hello,
I have two classes Main and Linked. The relation between them is one-to-one. The ID is generated by Main and referenced by Linked. The classes Main and Linked inherit from BusinessObject which contains an 'ID' property.
If I do
Code:
PersistenceHelper helper = new PersistenceHelper();
Main m = new Main();
helper.Save(m);
(the persistance helper does nothing except a transaction and a standard Save), with the attribute cascade="all" (as it is in the code below), the Main instance is saved but not the Linked instance. If I delete the attribute cascade="all", it works correctly (both instances are stored in the database).
Any idea?
Thanks a lot,
Fred
Mapping documents:Code:
<class name="BusinessLayer.Main, BusinessLayer">
<id name="ID" column="MainID">
<generator class="hilo"/>
</id>
<one-to-one name="Linked" cascade="all"/>
</class>
<class name="BusinessLayer.Linked, BusinessLayer">
<id name="ID" column="LinkedID">
<generator class="foreign">
<param name="property">Main</param>
</generator>
</id>
<one-to-one name="Main"/>
</class>
Classes:Code:
public class Main : PersistenceFramework.BusinessObject
{
public Main() { this._linked = new Linked(this); }
private Linked _linked;
public Linked Linked
{
get { return this._linked; }
private set { this._linked = value; }
}
}
public class Linked : PersistenceFramework.BusinessObject
{
public Linked(Main main)
{
this._main = main;
}
private Linked() { }
private Main _main;
public Main Main
{
get { return this._main; }
private set { this._main = value; }
}
}
Database:Main(MainID <PK>)
Linked(LinkedID <PK,FK>)
Linked.LinkedID --> Main.MainID[/code]