Possible bug with "offset" and PagedResultList

classic Classic list List threaded Threaded
1 message Options
Reply | Threaded
Open this post in threaded view

Possible bug with "offset" and PagedResultList

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?


- Jasen.

You received this message because you are subscribed to the Google Groups "Grails Dev Discuss" group.
To unsubscribe from this group and stop receiving emails from it, send an email to [hidden email].
To post to this group, send email to [hidden email].
To view this discussion on the web visit https://groups.google.com/d/msgid/grails-dev-discuss/db7a9fcf-b10c-467b-a173-0ab073fbf260%40googlegroups.com.
For more options, visit https://groups.google.com/d/optout.