I am using Hibernate 4.2, and i have a parent entity which contains a collections of child entities (One-To-Many ,fetch type is LAZY and annotated with @BatchSize(size=100))
.
If i query and load few parent entities and call access that collection which contains child object, hibernate uses the @BatchSize
as the expected.
But if i call session, flush and then do the same thing, it initializes collection only for that particular parent entity.
Is it the Hibernate expected behavior?
Edit: sample
List parents = criteria.list() parents.get(0).getXs().get(0) // triggers loading Xs of all parents
vs
List parents = criteria.list() session.flush() parents.get(0).getXs().get(0) // triggers loading Xs of only the first parent