-->
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: Fetch=join does not eager fetch collection
PostPosted: Fri Jul 17, 2009 11:38 am 
Newbie

Joined: Sun Apr 12, 2009 4:43 am
Posts: 11
Hi
I was following the examples in the 'Java Persistence and Hibernate' book with Hibernate 3.3.1 to try and load my collection upfront using fetch=join as follows:
Code:
<!-- Parent class -->
<hibernate-mapping>
    <class name="Person" table="PERSON">   
...       
       <set name="telephones" fetch="join" cascade="all-delete-orphan">
           <key column="PERSON_FK"/>
           <one-to-many class="Telephone"/>
       </set>
...
</hibernate-mapping>

<!-- Child collection class -->
<hibernate-mapping>
    <class name="Telephone" table="TELEPHONE">   
...   
        <property name="telNumber" column="TELNUMBER"/>
    </class>
</hibernate-mapping>


I would expect that when I do a session.get(Person.class, personId), that I would automatically fetch any associated Telephones and would not have to do e.g.
Hibernate.initialise(person.getTelephones).
However, the collection is not being fetched.

I tried putting lazy="false" in with fetch="join" and all that seemed to happen was an n+1 selects generated (which I want to avoid).

Any ideas?
thanks, Baljeet.


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.