I am trying to load distinct Parents using Criteria in Grails. The query is as following
Query:
def criteria = Parent.createCriter
You can achieve the same effect as with criteria.listDistinct
if you change the criteria query to include distinct root entity results transformer like this:
results = criteria.list(max:params.max, offset:params.offset){
children{
books{
like('title',"%book")
}
}
resultTransformer Criteria.DISTINCT_ROOT_ENTITY
order("id","asc")
}
There is however a reason why grails does not return paged results for the listDistinct call so it might be a case to resort to an HQL query with the in
operator