Could you please help me?
There is a case as bellow :
I have two classes VocherBDO and FinancialPeriodBDO
VocherBDO , FinancialPeriodBDO are lazy and all their properties are virtual
The problem is :
When loading VocherBDO, FinancialPeriodBDO is loaded whiteout any method call of FinancialPeriodBDO
VocherBDO.cs
*********************************************************************
using System;
using System.Collections;
using System.Reflection;
namespace CommonLibrary.TotalBusinessDataObject
{
///CommonLibrary.TotalBusinessDataObject.VocherBDO
/// <summary>
/// Summary description for VocherBDO.
/// </summary>
[Serializable]
public class VocherBDO : BaseBusinessDataObject
{
public VocherBDO(){}
private int _Id;
private string _VocherNumber;
private string _Date;
private FinancialPeriodBDO _FinancialPeriodBDO;
public virtual int id
{
set{ _Id = value; }
get{ return _Id; }
}
public virtual string vocherNumber
{
set{ _VocherNumber = value; }
get{ return _VocherNumber; }
}
public virtual string date
{
set{ _Date = value; }
get{ return _Date; }
}
public virtual FinancialPeriodBDO financialPeriodBDO
{
set { _FinancialPeriodBDO = value; }
get { return _FinancialPeriodBDO; }
}
}
}
<?xml version="1.0" encoding="utf-8" ?>
<hibernate-mapping xmlns="urn:nhibernate-mapping-2.0">
<class name="CommonLibrary.TotalBusinessDataObject.VocherBDO,CommonLibrary"
table="voucherView"
dynamic-update="true"
dynamic-insert="true"
lazy ="true">
<id name="id" column="id" type="Int32">
<generator class="identity" />
</id>
<property name="vocherNumber" column="vocherNumber" type="String" update="true" insert="true" />
<property name="date" column="date" type="String" update="true" insert="true" />
<many-to-one name="financialPeriodBDO" class="CommonLibrary.TotalBusinessDataObject.FinancialPeriodBDO, CommonLibrary"
column="financialPeriodId" not-null="true" outer-join="false"
update="false" insert="false" />
</class>
</hibernate-mapping>
*********************************************************************
FinancialPeriodBDO.cs
using System;
namespace CommonLibrary.TotalBusinessDataObject
{
/// <summary>
/// Summary description for FinancialPeriod.
/// </summary>
[Serializable]
public class FinancialPeriodBDO : BaseBusinessDataObject
{
public FinancialPeriodBDO()
{}
private int _Id;
private string _Code;
private string _Title;
public virtual int id
{
set{ _Id = value; }
get{ return(_Id); }
}
public virtual string code
{
set{ _Code = value; }
get{ return(_Code); }
}
public virtual string title
{
set{ _Title = value; }
get{ return(_Title); }
}
}
}
<?xml version="1.0" encoding="utf-8" ?>
<hibernate-mapping xmlns="urn:nhibernate-mapping-2.0">
<class name="CommonLibrary.TotalBusinessDataObject.FinancialPeriodBDO, CommonLibrary"
table="financialPeriod"
lazy ="true">
<id name="id" column="id" type="Int32">
<generator class="identity" />
</id>
<property name="code" column="code" type="String" />
<property name="title" column="title" type="String" />
/class>
</hibernate-mapping>
*********************************************************************
public void GetVocher()
{
ISession aSession = sessionFactory.OpenSession();
VocherBDO aVocherBDO = new VocherBDO();
aSession.Load(aVocherBDO,1);
sessionFactory.Close();
}
|