Hi Anthony,
Your HQL is working fine but returning duplicate records of parent as relation is many-to-one from child,
so I applied distinct over parent selection then it works fine.
but the query results should be paginated as it could be big. so when I applied "Query.setMaxResults" on the query generated SQL distincts over row number and again I got duplicates!
Is there any way to avoid duplicates?!
HQL
select distinct c.parent
from child c
where c.xxx
and c.yyy
apply qry.setMaxResults on above HQL
Generated SQL will be as below
select * from ( select distinct rownumber() over() as row_, parent1_.ID as ID from DB2ADMIN.Parent parent1_,
DB2ADMIN.Child child1_ ....) as temp_ where row_ <= ?
Thanks & Regards,
Surya
|