I've many-to-one and one-to-one properties in a proxied class and all my property and methods are virtual...when I load the object, NHibernate still loads the one-to-one property but not the many-to-ones? I think it's a bug in NHibernate because when I change the mapping of one-to-one to many-to-one, then none of the many-to-one are loaded. Below are my mapping files:
Code:
<?xml version="1.0" encoding="utf-8" ?>
<hibernate-mapping xmlns="urn:nhibernate-mapping-2.0">
<class name="WaterTrax.WTX.WTXObjectModel.DWFacSiteMsrmt, WTXObjectModel"
table="tDWFacSiteMsrmts" proxy="WaterTrax.WTX.WTXObjectModel.DWFacSiteMsrmt, WTXObjectModel">
<id name="id" column="DWMsrmtID">
<generator class="native" />
</id>
<one-to-one name="criteria" class="WaterTrax.WTX.WTXObjectModel.MeasurementWithCriteria, WTXObjectModel" />
<many-to-one name="dwFacSite"
class="WaterTrax.WTX.WTXObjectModel.DWFacSite, WTXObjectModel"
column="DWFacSiteID"/>
<property name="alertTypeID" column="AlertTypeID"/>
<set name="msrmtPresenceAlerts" inverse="true" lazy="true">
<key column="DWFacSiteMsrmtID"/>
<one-to-many class="WaterTrax.WTX.WTXObjectModel.MsrmtPresenceAlert, WTXObjectModel"/>
</set>
...
</class>
</hibernate-mapping>
Code:
<?xml version="1.0" encoding="utf-8" ?>
<hibernate-mapping xmlns="urn:nhibernate-mapping-2.0">
<class name="WaterTrax.WTX.WTXObjectModel.MeasurementWithCriteria, WTXObjectModel"
table="vw_MeasurementWithCriteria" proxy="WaterTrax.WTX.WTXObjectModel.MeasurementWithCriteria, WTXObjectModel" mutable="false">
<id name="id" column="DWMsrmtID" unsaved-value="0">
<generator class="native" />
</id>
<one-to-one name="msrmt" class="WaterTrax.WTX.WTXObjectModel.DWFacSiteMsrmt, WTXObjectModel" />
<property name="type" column="ComparisonLevelLabel" />
<property name="minVal" column="ReportComparisonMinValue" type="Nullables.NHibernate.NullableDoubleType, Nullables.NHibernate"/>
<property name="maxVal" column="ReportComparisonMaxValue" type="Nullables.NHibernate.NullableDoubleType, Nullables.NHibernate"/>
<property name="minDecimals" column="ReportComparisonMinDecimals"/>
<property name="maxDecimals" column="ReportComparisonMaxDecimals"/>
<many-to-one name="unit"
class="WaterTrax.WTX.WTXObjectModel.Unit, WTXObjectModel"
column="ReportComparisonUnitsID"/>
...
</class>
</hibernate-mapping>
Here's the log file, and notice that it's going to the DB to load:
Code:
006-01-16 17:17:20,143 DEBUG [ NHibernate.Impl.SessionImpl] - resolving associations for: [WaterTrax.WTX.WTXObjectModel.LogSheetMsrmt#1443396]
2006-01-16 17:17:20,143 DEBUG [ NHibernate.Impl.SessionImpl] - resolving associations for: [WaterTrax.WTX.WTXObjectModel.LogSheetMsrmt#1443396]
2006-01-16 17:17:20,143 DEBUG [ NHibernate.Impl.SessionImpl] - loading [DWFacSiteMsrmt#857038]
2006-01-16 17:17:20,143 DEBUG [ NHibernate.Impl.SessionImpl] - loading [DWFacSiteMsrmt#857038]
2006-01-16 17:17:20,143 DEBUG [ NHibernate.Impl.SessionImpl] - attempting to resolve [DWFacSiteMsrmt#857038]
2006-01-16 17:17:20,143 DEBUG [ NHibernate.Impl.SessionImpl] - attempting to resolve [DWFacSiteMsrmt#857038]
2006-01-16 17:17:20,143 DEBUG [ NHibernate.Impl.SessionImpl] - resolved object in session cache [WaterTrax.WTX.WTXObjectModel.DWFacSiteMsrmt#857038]
2006-01-16 17:17:20,143 DEBUG [ NHibernate.Impl.SessionImpl] - resolved object in session cache [WaterTrax.WTX.WTXObjectModel.DWFacSiteMsrmt#857038]
2006-01-16 17:17:20,143 DEBUG [ NHibernate.Impl.SessionImpl] - loading [LogSheetSample#378642]
2006-01-16 17:17:20,143 DEBUG [ NHibernate.Impl.SessionImpl] - loading [LogSheetSample#378642]
2006-01-16 17:17:20,143 DEBUG [ NHibernate.Impl.SessionImpl] - attempting to resolve [LogSheetSample#378642]
2006-01-16 17:17:20,143 DEBUG [ NHibernate.Impl.SessionImpl] - attempting to resolve [LogSheetSample#378642]
2006-01-16 17:17:20,143 DEBUG [ NHibernate.Impl.SessionImpl] - resolved object in session cache [WaterTrax.WTX.WTXObjectModel.LogSheetSample#378642]
2006-01-16 17:17:20,143 DEBUG [ NHibernate.Impl.SessionImpl] - resolved object in session cache [WaterTrax.WTX.WTXObjectModel.LogSheetSample#378642]
...
2006-01-16 17:17:20,163 DEBUG [ NHibernate.Impl.SessionImpl] - loading [Unit#111]
2006-01-16 17:17:20,163 DEBUG [ NHibernate.Impl.SessionImpl] - loading [Unit#111]
2006-01-16 17:17:20,163 DEBUG [ NHibernate.Impl.SessionImpl] - attempting to resolve [Unit#111]
2006-01-16 17:17:20,163 DEBUG [ NHibernate.Impl.SessionImpl] - attempting to resolve [Unit#111]
2006-01-16 17:17:20,163 DEBUG [ NHibernate.Impl.SessionImpl] - resolved object in session cache [WaterTrax.WTX.WTXObjectModel.Unit#111]
2006-01-16 17:17:20,163 DEBUG [ NHibernate.Impl.SessionImpl] - resolved object in session cache [WaterTrax.WTX.WTXObjectModel.Unit#111]
2006-01-16 17:17:20,163 DEBUG [ NHibernate.Impl.SessionImpl] - loading [MeasurementWithCriteria#857038]
2006-01-16 17:17:20,163 DEBUG [ NHibernate.Impl.SessionImpl] - loading [MeasurementWithCriteria#857038]
2006-01-16 17:17:20,163 DEBUG [ NHibernate.Impl.SessionImpl] - attempting to resolve [MeasurementWithCriteria#857038]
2006-01-16 17:17:20,163 DEBUG [ NHibernate.Impl.SessionImpl] - attempting to resolve [MeasurementWithCriteria#857038]
2006-01-16 17:17:20,163 DEBUG [ NHibernate.Impl.SessionImpl] - object not resolved in any cache [WaterTrax.WTX.WTXObjectModel.MeasurementWithCriteria#857038]
2006-01-16 17:17:20,163 DEBUG [ NHibernate.Impl.SessionImpl] - object not resolved in any cache [WaterTrax.WTX.WTXObjectModel.MeasurementWithCriteria#857038]
2006-01-16 17:17:20,163 DEBUG [Hibernate.Persister.EntityPersister] - Materializing entity: WaterTrax.WTX.WTXObjectModel.MeasurementWithCriteria#857038
2006-01-16 17:17:20,163 DEBUG [Hibernate.Persister.EntityPersister] - Materializing entity: WaterTrax.WTX.WTXObjectModel.MeasurementWithCriteria#857038
2006-01-16 17:17:20,163 DEBUG [ NHibernate.Driver.DriverBase] - setting ADO Command timeout to '600' seconds
2006-01-16 17:17:20,163 DEBUG [ NHibernate.Driver.DriverBase] - setting ADO Command timeout to '600' seconds
2006-01-16 17:17:20,163 DEBUG [ NHibernate.Impl.BatcherImpl] - Opened new IDbCommand, open IDbCommands :1
2006-01-16 17:17:20,163 DEBUG [ NHibernate.Impl.BatcherImpl] - Opened new IDbCommand, open IDbCommands :1
2006-01-16 17:17:20,163 DEBUG [ NHibernate.Impl.BatcherImpl] - Building an IDbCommand object for the SqlString: SELECT measuremen0_.DWMsrmtID as DWMsrmtID2_, measuremen0_.ComparisonLevelLabel as Comparis2_2_, measuremen0_.ReportComparisonMinValue as ReportCo3_2_, measuremen0_.ReportComparisonMinDecimals as ReportCo5_2_, measuremen0_.ExceedOnOverGrowth as ExceedO10_2_, measuremen0_.ReportComparisonMaxValue as ReportCo4_2_, measuremen0_.ExceedOnPresence as ExceedOn8_2_, measuremen0_.ExceedOnPresumptive as ExceedOn9_2_, measuremen0_.ReportComparisonUnitsID as ReportCo7_2_, measuremen0_.ReportComparisonMaxDecimals as ReportCo6_2_, dwfacsitem1_.DWMsrmtID as DWMsrmtID0_, dwfacsitem1_.DetectLimit as DetectLi2_0_, dwfacsitem1_.UpperDetectLimit as UpperDet3_0_, dwfacsitem1_.DWFacSiteID as DWFacSit6_0_, dwfacsitem1_.ReadingID as ReadingID0_, dwfacsitem1_.DetectLimitDecimalPlaces as DetectLi4_0_, dwfacsitem1_.ReadingTypeID as ReadingT7_0_, dwfacsitem1_.AlertTypeID as AlertTy12_0_, dwfacsitem1_.MinAlertValue as MinAler13_0_, dwfacsitem1_.UnitsID as UnitsID0_, dwfacsitem1_.UpperDetectLimitDecimalPlaces as UpperDet5_0_, dwfacsitem1_.AlertSource as AlertSo11_0_, dwfacsitem1_.MaxAlertValue as MaxAler14_0_, dwfacsitem1_.Descr as Descr0_, measuremen2_.DWMsrmtID as DWMsrmtID1_, measuremen2_.ComparisonLevelLabel as Comparis2_1_, measuremen2_.ReportComparisonMinValue as ReportCo3_1_, measuremen2_.ReportComparisonMinDecimals as ReportCo5_1_, measuremen2_.ExceedOnOverGrowth as ExceedO10_1_, measuremen2_.ReportComparisonMaxValue as ReportCo4_1_, measuremen2_.ExceedOnPresence as ExceedOn8_1_, measuremen2_.ExceedOnPresumptive as ExceedOn9_1_, measuremen2_.ReportComparisonUnitsID as ReportCo7_1_, measuremen2_.ReportComparisonMaxDecimals as ReportCo6_1_ FROM vw_MeasurementWithCriteria measuremen0_ left outer join tDWFacSiteMsrmts dwfacsitem1_ on measuremen0_.DWMsrmtID=dwfacsitem1_.DWMsrmtID left outer join vw_MeasurementWithCriteria measuremen2_ on dwfacsitem1_.DWMsrmtID=measuremen2_.DWMsrmtID WHERE measuremen0_.DWMsrmtID=:DWMsrmtID