I am using a Criteria query on a domain object which returns a PagedResultList.
Something like this:
def c = Book.createCriteria()
def result = c.list(params) {
// a list of various criteria
}
def resultMap = ["resultCount": result.totalCount, "records": result]
return resultMap // gets rendered as JSON. The JSON contains the count & the items for the current page
If the "params" map does not contain "offset", I get the results I expect. However, if I include "offset" and the number of items returned is small (I have not thoroughly investigated what qualifies as "small" but 2-5 records shows the problem), I get a correct result.totalCount, but "result" is empty.
For example, "offset=0" yields:
{
"resultCount": 2,
"records": []
}
I have copy & pasted the SQL generated by Hibernate (with the offset clause) and the SQL returns the expected records.
I have tried the following:
println "result class = ${result.class}\n resultList = ${result.resultList}\n array = ${result.toArray()}"
And the list & array are empty. So it appears something is preventing the PagedResultList from being populated with the records.
Before I file a bug report or go looking around in the source, can someone tell me if I'm doing something wrong or missing something?
Thanks.
- Jasen.