I can not get the list to work ; I am using list to keep indexes too; i managed to save the list objects successfully "not straight forward though" to the database but can not load list objects back at all
I have these classes
Code:
Class Base
{
private string mID;
public string ID
{
get {return mID;}
set {mID = valuse}
}
}
Class A : Base
{
private IList mBs;
public IList Bs
{
get{return mName;}
set{mName = value;}
}
}
Class B : Base
{
private A mParentA;
public A ParentA
{
get {return mParentA;}
set {mParentA = value;}
}
}
And the mappings for them are
Code:
<class name="DataModel.Base, DataModelDemo" table="Base">
<id name="ID">
<generator class="assigned"/>
</id>
</class>
<joined-subclass name="DataModel.A, DataModelDemo" table="A" extends="DataModel.Base, DataModelDemo">
<key column="UID"/>
<list name="Bs" cascade="all" table="B" inverse="false">
<key column="A_ID"/>
<index column="seq"/>
<one-to-many class="DataModel.B, DataModelDemo"/>
</list>
</joined-subclass>
<joined-subclass name="DataModel.B, DataModelDemo" table="B" extends="DataModel.Base, DataModelDemo" dynamic-insert="true" dynamic-update="true" lazy="false">
<key column="ID" />
<many-to-one name="ParentA" column="A_ID" not-null="true" cascade="none"/>
</joined-subclass>
--1--now this code does not work properly I got no exceptions but when I add an instance of class A to the session the IList turns to undefined value !! can i keep the array list ???
--2-- so I have to reinitialize it again and then add instances of class B to the List "This does not add them to database" is there persistence by reachability ?
so i added each instance of class B to the session and then commited the session which then added the Bs to database successfully
--3-- now i try to retrieve A object from database using
Code:
nhSession.CreateCriteria(typeof(DataModel.A)).List();
this retrieves the A's objects successfully but with undefined lists !!!!!
I tried
Code:
NHibernateUtil.Initialize(AObject);
OR
NHibernateUtil.Initialize(aObject.Bs);
With no success always undefined list;
Clearly I am missing something ,,, Any help is appreciated;
Thanks