Hi,
Let us say that I have a Parent-Child relationship, where one Parent can have multiple Children. Parent object has a collection of Child objects.
Is it possible to query for all Parents that have certain children (children older than 16 years)? What I would like to get by the Hibernate is a collection Parent objects (matching the above condition) with their children collection populated only with those children that are matching the above condition.
For the following example:
Parent 1 (Child 1a (15yrs), Child 1b (10yrs)) Parent 2 (Child 2a (18yrs), Child 2b (9yrs)) Parent 3 (Child 3a (11yrs), Child 3b (20yrs), Child 3c (19yrs))
The result should be a collection of Parent objects initialized as:
Parent 2 (Child 2a (18yrs)) Parent 3 (Child 3b (20yrs), Child 3c (19yrs))
Is it possible to create such mapping/query in Hibernate and how?
Regards
|