-->
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: N+1 Select Problem using Dynamic Fetching w/ Criteria
PostPosted: Sun Sep 23, 2007 1:11 am 
Newbie

Joined: Wed Aug 17, 2005 3:02 pm
Posts: 7
I have 3 classes A, B and C. Class A contains a set of B and class B contains a set of C. Set B is globally lazy in A and set C is globally lazy in B and both with outer-join set to auto.

In my DAO, I'm trying to get a list of A inner join B inner join C:
Code:
Criteria criteria = session.createCriteria(A.class);
criteria.createAlias("bs", "b", CriteriaSpecification.INNER_JOIN)
    .setFetchMode("b", FetchMode.JOIN);
criteria.createAlias("b.cs", "c", CriteriaSpecification.INNER_JOIN)
    .setFetchMode("c", FetchMode.JOIN);
criteria.setResultTransformer(CriteriaSpecification.DISTINCT_ROOT_ENTITY);
criteria.list();


The resulting SQL does indeed show the joins for entities B and C but my log file also shows a bunch of SQL generated when I tried to access the B and C collections.

Note that the data returned is exactly what I want and yes, I really want to perform inner joins. I'm just curious why the all the extra SQL calls are being made when it appears as though everything should have been returned from the first SQL query.

Hibernate version: 3.2.2.ga

Database: Oracle 9i


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.