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?