-->
These old forums are deprecated now and set to read-only. We are waiting for you on our new forums!
More modern, Discourse-based and with GitHub/Google/Twitter authentication built-in.

All times are UTC - 5 hours [ DST ]



Forum locked This topic is locked, you cannot edit posts or make further replies.  [ 1 post ] 
Author Message
 Post subject: key-many-to-one not respecting inner/outer join fetch
PostPosted: Thu Oct 19, 2006 5:24 am 
Newbie

Joined: Wed Mar 16, 2005 7:15 am
Posts: 2
Location: London, UK
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


Top
 Profile  
 
Display posts from previous:  Sort by  
Forum locked This topic is locked, you cannot edit posts or make further replies.  [ 1 post ] 

All times are UTC - 5 hours [ DST ]


You cannot post new topics in this forum
You cannot reply to topics in this forum
You cannot edit your posts in this forum
You cannot delete your posts in this forum

Search for:
© Copyright 2014, Red Hat Inc. All rights reserved. JBoss and Hibernate are registered trademarks and servicemarks of Red Hat, Inc.