-->
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: Multi-level non-lazy loading fails
PostPosted: Tue Nov 28, 2006 4:41 am 
Newbie

Joined: Mon Nov 06, 2006 9:50 am
Posts: 4
I have a tree of objects I wish to load in a single step, without lazy loading. However, I can't get Hibernate to load the tree more than one level deep.

My situation:
Code:
class Group {
   private SortedSet<Member> members;
   ...
}

class Member {
  private Category category;
  ...
}

class Category {
...
}


The mapping is as follows:

Code:
<class name="my.package.Group" table="groups">
  <set name="members" lazy="false" sort="natural">
    <key column="group_id" />
    <one-to-many class="my.package.Member"/>
  </set>
  ...
</class>

<class name="my.package.Member" table="members">
  <one-to-one name="category" class="my.package.Category" foreign-key="category_id" lazy="false"/>
  ...
</class>
<class name="my.package.Category" table="categories">
  ...
</class>


Loading a Group will include the Members, and loading a Member will include the Category, but I need it so that the Category is included when I load the Group. This fails no matter how I load the Group (by id, query).

Any suggestions?


Top
 Profile  
 
 Post subject:
PostPosted: Tue Nov 28, 2006 4:46 am 
Newbie

Joined: Mon Nov 06, 2006 9:50 am
Posts: 4
Actually, the problem appears to be that Hibernate loads the Category for the first Member of Group, but not for the others!


Top
 Profile  
 
 Post subject:
PostPosted: Tue Nov 28, 2006 4:57 am 
Newbie

Joined: Mon Nov 06, 2006 9:50 am
Posts: 4
Solved it myself - I really needed a many-to-one relationship here.


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.