Question

If I have a parent object (Parent) which has a List(Of Child) objects as a many-one relationship. Is it possible to return a Parent with a subset of it's child objects (eagerly loaded)? I am using VB and Criteria.

e.g. If Parent 1 has 50 children (20 type X 30 type Y) and I want to return the Parent with a collection containing only type X.

I only want a collection with a size of 20 with it's eagerly loaded children?

Thanks

Was it helpful?

Solution

HQL query. The fetch keyword will initialize the children along with the parent.

from parent left join fetch parent.Children as child where child.type = X
Licensed under: CC-BY-SA with attribution
Not affiliated with StackOverflow
scroll top