Hi,
Runtime fetching strategy sounds like a very interesting feature. So I played with it. I have a recursive relationship (parent/children) for entity A mapped using:
Code:
<set name="children" lazy="true" inverse="true" cascade="save-update">
<key column="parent_id" />
<one-to-many class="A" />
</set>
<many-to-one name="parent" class="A" column="parent_id" />
I have a following scenario. Load root of the tree and serialize it to the other VM. If I set lazy to false and load the root then the whole tree of A objects is loaded. That is what I expected. If I set lazy to true, children don't get loaded and I get Exception while accessing them. Excellent.
Now if I set the runtime fetch parameter of the Criteria to be eager and keep the lazy to be true only the root and its children are loaded while other nodes deeper in the tree are not loaded.
How can we specify using Criteria API that indeed we want the whole tree loaded?
Regards,
Vladimir