Hibernate version: 3.2
Basically I have a class containing a collection of a class that contains another collection. All mappings for collections are set to be lazy.
Stripped down mapping:
Code:
<class name="TheClass">
<set name="collection1" lazy="true">
<one-to-many class="OtherClass"/>
</set>
</class>
<class name="OtherClass">
<list name="collection2" lazy="true">
<many-to-many class="YetAnotherClass"/>
</list>
</class>
First retrieve theClass:
Code:
TheClass theClass = theClassDAO.getTheClass(id);
Since I'm using lazy, collection1 hasn't been loaded. Fine, now I want to load collection1:
Code:
Hibernate.initialize(theClass.getCollection1);
Hibernate will now also load collection2 even though it's tagged as lazy. Is this the default behaviour for Hibernate.initialize()? The entire tree will be loaded?
I had expected only collection1 to be loaded. Much obliged for any comments.