Hi...
The problem is in your EntityTableB... you use the ID from EntityTableA it's wrong... you have to use EntityTableA... see:
Quote:
public class EntityTableA
{
private int _f1;
private IList<EntityTableB> _BF1=new list<EntityTableB>();
public virtual int f1
{
..etc
}
public virtual IList<EntityTableB> BF2
{
...etc
}
}
public class EntityTableB
{
private int _BF1
private EntityTableA _BF2;
public virutal int BF1
{
..etc
}
public virtual EntityTableA BF2
{
...etc
}
}
}
now, the mapping:
Quote:
<?xml version="1.0" encoding="utf-8" ?>
<hibernate-mapping xmlns="urn:nhibernate-mapping-2.2">
<class name="EntityTableA" table="TableA" >
<id name="f1" column="f1" type="System.Int32" unsaved-value="0">
<generator class="identity" />
</id>
<bag name="BF2" table="TableB" cascade="all" lazy="false">
<key column="f1"/>
<one-to-many class="EntityTableA"/>
</bag>
</class>
</hibernate-mapping>
<?xml version="1.0" encoding="utf-8" ?>
<hibernate-mapping xmlns="urn:nhibernate-mapping-2.2">
<class name="BF1" table="TableB" >
<id name="BF1" column="BF1" type="Int32" unsaved-value="0">
<generator class="identity" />
</id>
<many-to-one name="BF2" class="EntityTableA" column="f1" />
</class>
</hibernate-mapping>
I think this solve your problem.