Joined: Tue Jul 15, 2008 3:55 pm Posts: 5
|
This is jus Sample which resembles with my actual tables..
Table A
f1 int
f2 int FK(References BF1 of Table B)
Table B
BF1 int
BF2 int ( References to Table A f1)
<?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="coll_f2" 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>
<property name="BF2" column="BF2" type="Int32" length="4" />
</class>
</hibernate-mapping>
Question:
When i load "EntityTableA" am getting the data and it is working fine but when i update collection(EntityTableB) using following code it is throwing error.
ICriteria criteria = _session.CreateCriteria(typeof(EntityTableA));
criteria.Add(NHibernate.Expression.Expression.Eq("f1", 1));
EntityTableA dPop = new EntityTableA();
dPop = (EntityTableA)criteria.List()[0];
dPop.EntityTableB = null; // -- Here am making Table B entity as null
_session.SaveOrUpdate(dPop);
please help me..
|
|