-->
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.  [ 2 posts ] 
Author Message
 Post subject: Help with Query
PostPosted: Wed Jul 22, 2009 6:19 pm 
Newbie

Joined: Wed Jun 24, 2009 12:24 pm
Posts: 5
I have an object tree with 3 levels of nested one-to-many relationships:

A has-a Set<B>, B has-a Set<C> and C has-a Set<D>

All the set mappings are like this one in A.hbm.xml:
Code:
    <set name="set_of_b" cascade="all">
        <key column="A_ID" not-null="true"/>
        <one-to-many class="B"/>
    </set>

I want to write a query that returns an instance of A (id is provided) with all the nested sets fully populated (as if fetching is eager).

If I use fetch="join" in the set mappings, then it works out, but that would not be allowed.

I've tried the following query, but it's not working:
Code:
            A a = (A) s.createCriteria(A.class)
                                .add(Restrictions.idEq(a_id))
                                .setFetchMode("set_of_b", FetchMode.JOIN)
                                    .createCriteria("set_of_b")
                                    .setFetchMode("set_of_c", FetchMode.JOIN)
                                        .createCriteria("set_of_d")
                                        .setFetchMode("set_of_d", FetchMode.JOIN)
                                .uniqueResult();

Please help.


Top
 Profile  
 
 Post subject: Re: Help with Query
PostPosted: Thu Jul 23, 2009 10:12 am 
Newbie

Joined: Wed Jun 24, 2009 12:24 pm
Posts: 5
no help? :-(

please at least let me know if it is not possible or too dumb a question?


Top
 Profile  
 
Display posts from previous:  Sort by  
Forum locked This topic is locked, you cannot edit posts or make further replies.  [ 2 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.