-->
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: Many-to-one with outer-join still results in n+1 selects
PostPosted: Wed Apr 12, 2006 11:30 am 
Newbie

Joined: Wed Jun 08, 2005 10:45 am
Posts: 3
Need help with Hibernate? Read this first:
http://www.hibernate.org/ForumMailingli ... AskForHelp

Hibernate version: 3.0.5

Mapping documents:
<class name="com.dcs.mcass.domain.Application" table="MCASS.APPLICATION">
<id name="contractId" column="I_CONTRACT_ID" type="long">
<generator class="foreign">
<param name="property">contract</param>
</generator>
</id>
...
<many-to-one name="dealer" class="com.dcs.mcass.domain.Dealer" column="C_DEALER_ID" insert="false" update="false" not-found="ignore"/>
/>


Code between sessionFactory.openSession() and session.close():

The following hql executes an outer join for dealer as expected but still does a separate select for it as well.

select a from Application a
left join fetch a.dealer d



Full stack trace of any exception that occurs:

Name and version of the database you are using: UDB 8.0.2

The generated SQL (show_sql=true):
select ... from MCASS.APPLICATION applicatio0_
left outer join MCASS.DEALER dealer3_ on applicatio0_.C_DEALER_ID=dealer3_.C_DEALER_ID

// still getting n+1 select
select ... from MCASS.DEALER dealer0_ where dealer0_.C_DEALER_ID=?


Debug level Hibernate log excerpt:


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.