Hi,
I am trying to query the number of children in a parent/child relationship with a filter. I am using field access and the getChildren() getter in my parent entity returns an unmodifiable collection set (all by the book). Except that the createFilter() method fails with this exception:
Code:
[junit] The collection was unreferenced
[junit] org.hibernate.QueryException: The collection was unreferenced
[junit] at org.hibernate.impl.SessionImpl.getFilterQueryPlan(SessionImpl.java:1464)
[junit] at org.hibernate.impl.SessionImpl.createFilter(SessionImpl.java:1274)
Here's the code:
Code:
Long num = (Long) getSession()
.createFilter(parent.getChildren(), "select count(*)")
.uniqueResult();
Modifying the getChildren() method to return the actual collection works but that breaks the design/constraint. Is there any other way to go about this?
Thanks.