Could anyone confirm if many-to-one associations should be resolved by Nhibernate using a single query with joins when outer-join is set to true?
To make it clear, I have the following simple mapping:
Code:
<hibernate-mapping xmlns="urn:nhibernate-mapping-2.0">
<class name="SimpleTest.Deal, SimpleTest" table="DEA_DEAL">
<id name="DealID" column="DEA_ID" type="Int32" unsaved-value="0">
<generator class="sequence">
<param name="sequence">DEA_SEQ</param>
</generator>
</id>
<property name="Date" type="DateTime" column="DEA_DT" />
<many-to-one name="AccountingPortfolio" class="SimpleTest.Portfolio, SimpleTest"
column="DEA_ID_APRF" outer-join="true"/>
<many-to-one name="TradingPortfolio" class="SimpleTest.Portfolio, SimpleTest"
column="DEA_ID_TPRF" outer-join="true"/>
<many-to-one name="Instrument" class="SimpleTest.GenericInstrument, SimpleTest" column="DEA_ID" outer-join="true"/>
</class>
<class name="SimpleTest.GenericInstrument, SimpleTest" table="DEA_INSTRUMENT">
<id name="InstrumentID" column="ITR_ID" type="Int32" unsaved-value="0">
<generator class="sequence">
<param name="sequence">ITR_SEQ</param>
</generator>
</id>
<many-to-one name="TradingPortfolio" class="SimpleTest.Portfolio, SimpleTest"
column="ITR_ID_TPRF" />
<bag name="InstrumentSequence" inverse="false" lazy="true" order-by="ITR_ID" where="ITR_DTDELETE = to_date('01013000', 'ddmmyyyy')" >
<key column="ITR_ID_ITR" />
<one-to-many class="SimpleTest.GenericInstrument, SimpleTest"/>
</bag>
</class>
<class name="SimpleTest.Portfolio, SimpleTest" table="PTF_PORTFOLIO" where="PTF_DTDELETE = to_date('01013000', 'ddmmyyyy')" mutable="false">
<id name="Id" column="PTF_ID" type="Int32" unsaved-value="0">
<generator class="sequence">
<param name="sequence">PRF_SEQ</param>
</generator>
</id>
<property name="Code" type="String" column="PTF_CD" />
<property name="Name" type="String" column="PTF_NAME" />
<property name="DeleteDate" column="PTF_DTDELETE" type="DateTime"/>
<property name="UpdateDate" column="PTF_LASTUPD" type="DateTime"/>
</class>
</hibernate-mapping>
when I run the following HQL: "from Deal"
I would expect the portfolio and instrument to be loaded in a single select, but nhibernate keeps running several selects to resolve the many-to-one associations. Is that a normal behavior?