I have the following HQL query
SELECT ob FROM objectBase ob WHERE size(ob.listSC) > 0 AND ob.listSC.registrationDate BETWEEN :startDate AND :endDate
What it is supposed to do:
But unfortunately it gives me
Caused by: org.hibernate.QueryException: illegal attempt to dereference collection [objectbase0_.id.listSC] with element property reference [registrationDate]
at org.hibernate.hql.internal.ast.tree.DotNode$1.buildIllegalCollectionDereferenceException(DotNode.java:73)
Which is for a good reason I believe. The question is how to implement such behaviour anyway? Preferably, without using JOINs.
Thanks in advance.
Please try below query if you need any help let me know.
SELECT ob FROM objectBase ob left join ob.listSC sc WHERE size(ob.listSC) > 0 AND sc.registrationDate BETWEEN :startDate AND :endDate