-->
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.  [ 3 posts ] 
Author Message
 Post subject: unnecessary (?) loading entities
PostPosted: Sat Mar 24, 2007 12:39 pm 
Newbie

Joined: Sun Apr 16, 2006 1:02 pm
Posts: 12
Hibernate version:

3.2

Table Urls contains urls, GzHtml the corresponding fetched HTML and GzText basicly the HTML with stripped off tags etc.

Find records in GzHtml which don't yet exist in GzText:

SQL:
Code:
          SELECT id, url, htmlFROM
          (
            SELECT url_id, html FROM gzhtml WHERE url_id NOT IN
            (
              SELECT url_id FROM gztext
            )
          ) AS diff
          INNER JOIN urls ON diff.url_id = urls.id;

HQL:
Code:
FROM Urls u JOIN FETCH u.gzHtml h WHERE u.id = h.urlId AND u.id NOT IN (SELECT urlId FROM GzText)

At least both return the same result count n but the HQL version load n times a GzText (?!) entity. Why is that and esp. what is it loading? These n GzText records are actually *missing* in GzText.


Top
 Profile  
 
 Post subject:
PostPosted: Sat Mar 24, 2007 1:35 pm 
Expert
Expert

Joined: Tue Dec 28, 2004 7:02 am
Posts: 573
Location: Toulouse, France
Try calling setResultTransformer(Criteria.DISTINCT_ROOT_ENTITY) on your query before calling list().

_________________
Baptiste
PS : please don't forget to give credits below if you found this answer useful :)


Top
 Profile  
 
 Post subject:
PostPosted: Sat Mar 24, 2007 1:53 pm 
Newbie

Joined: Sun Apr 16, 2006 1:02 pm
Posts: 12
batmat wrote:
Try calling setResultTransformer(Criteria.DISTINCT_ROOT_ENTITY) on your query before calling list().


Still the same behaviour.


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

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.