-->
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.  [ 4 posts ] 
Author Message
 Post subject: How can I load only the parent object without children objec
PostPosted: Thu Apr 14, 2005 11:12 am 
Newbie

Joined: Mon Sep 01, 2003 10:40 am
Posts: 17
I have a Parent object with 2 one-to-many relations like this

Code:
<class name="MyParentClass" table="MyParentTable" dynamic-update="true">
.....
<set name="childOne" inverse="true" >
            <key>
                <column name="PkChildOne"/>
             </key>
            <one-to-many class="ChildOne"/>
  </set>
<set name="childTwo" inverse="true">
            <key>
                <column name="PkChildTwo"/>
             </key>
            <one-to-many class="ChildTwo"/>
  </set>

......



Any time I want load MyParentClass with all children (with session.load(..)), but other time I want load only MyParentClass without all children (maybe with Criteria).

Any solution ?

[/code]


Top
 Profile  
 
 Post subject:
PostPosted: Fri Apr 15, 2005 12:47 am 
Beginner
Beginner

Joined: Mon Dec 15, 2003 5:25 am
Posts: 48
Location: Delhi, India
set fetchtype to LAZY

_________________
Vinod K. Singh


Top
 Profile  
 
 Post subject:
PostPosted: Sun Apr 17, 2005 2:54 am 
Newbie

Joined: Mon Sep 01, 2003 10:40 am
Posts: 17
I will use fetch=join into mapping and HQL for get only parent oject, becouse HQL does't react at fetch=join


Top
 Profile  
 
 Post subject:
PostPosted: Sun Apr 17, 2005 5:19 am 
Hibernate Team
Hibernate Team

Joined: Thu Dec 18, 2003 9:55 am
Posts: 1977
Location: France
Quote:
Any time I want load MyParentClass with all children (with session.load(..)), but other time I want load only MyParentClass without all children (maybe with Criteria).


set fetch="select" for your collections

if you want to load both collections then execute 2 hql queries:
select parent from Parent parent left fetch join parent.children1
then
select parent from Parent parent left fetch join parent.children2

all this in the same session, your graph will be entirely loaded

_________________
Anthony,
Get value thanks to your skills: http://www.redhat.com/certification


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