Hello,
I have a model where I have a big collection of an object type which has childs. I want hibernate to get a part of my collection and all childs in one select.
So I thought about "join fetch" which avoids n select to get the child of each object in the collection (where n is the size of the collection).
I didn't want to get the whole collection in my select so I think about setMaxResult() and better scroll() because it tells you if there are more objects.
But "join fetch" and scroll() don't work together...
I tried to understand why : If i take a
Code:
Collection<A>
and A has an attribute :
Code:
public class A{
private Collection<Thing> things;
and the HQL query :
Code:
"from A a left join fetch a.things where a member of ..."
then Hibernate can't sure that every element A of the collection get all its Thing before he reaches the end of the ResultSet of the query.
So if you use a scroll and stop scrolling before the end of the ResultSet, you may have invalid objects.
Am I right ?
It's important for me to understand why "join fetch" and scroll() don't work together because it can help me to solve my problem.
Thanks.
Fabrice
Hibernate version: 3.2.2.ga