Can you add a query restriction upon a child in a one to many association where only those matching children are returned in the result set?
We have a one-to-many from an unnormalised table to itself where the parent is a collection of properties resulting from an audit event. i.e an AuditEvent (EntityLog).
Code:
AuditEvent 1 ------------------ * AuditProperties
Is it possible to filter the set returned to only include AuditProperties which meet some criteria. At the moment AuditEvents are returned complete with all audit properties if only one AuditProperty matches.
Hibernate Version: 3.2.1.gaDB: MSSQL2000Query:Code:
String[] properties = new String[]{"p1, p2"};
createAlias("propertyAudits", "pa");
add(Restrictions.in("property", properties));
Note that the code is from a class which extends DetachedCriteriaFor example:
With the following rows, I would get one audit event (expected) containing two AuditProperties (unexpected) p1 and p3.
Code:
AuditEvent AuditProperty
1 p1
1 p3
3 p3
I can post more details, but I tried to keep it simple.
Thanks,
Wayne.