Using NHibernate 1.0.2.0 against Oracle 9.
I'm working with an existing schema which isn't using surrogate keys, and I have a composite key of the form:
Code:
<class name="CalculatedRating" ...>
<composite-id>
<key-property name="EffectiveDate" column="EFFECTIVE_DATE"/>
<key-many-to-one name="FdeOrganization" column="ORGANIZATION_ID" .../>
</composite-id>
...
</class>
Using this query:
Code:
from CalculatedRating cr
inner join fetch cr.FdeOrganization fdeOrg
left join fetch fdeOrg.Attributes as attribute
inner join fetch attribute.AttributeType
where cr.EffectiveDate =
(select max(cr2.EffectiveDate)
from CalculatedRating cr2
where cr2.EffectiveDate >= :EffectiveDate)
order by cr.FdeOrganization.OrgId
NHibernate is quite correctly generating the SQL necessary to completely manifest the CalculatedRating element in a single query. However, after executing that query, it then still proceeds to do the N+1 select on FdeOrganization.
As in this application I'm actually using quite a few cases where I'm successfully using the inner join fetch technique against FdeOrganization, I can only assume that this is a problem related to key-many-to-one rather than many-to-one.
Can someone confirm this?
Kirk Wylie