For the life of me I cannot understand why in a controller that inherits from RestfulController, that the index method only returns 4 rows. Is this a default setting? The same behavior happens when I override the method, like so.
import grails.rest.*
import grails.converters.*
class WidgitController extends RestfulController {
static responseFormats = ['json', 'xml']
WidgitController() {
super(Widgit)
}
@Override
def index() {
def w = Widgit.findAllWhere(isEnabled: true, [max: 10]) //w: sizec4
def w2 = listAllResources(params) //w2: size 4
respond w
}
}
Any help would be appreciated.
Turns out the problem comes under better focus when you look up paging.
depending on how your domain objects are spec'd out gorm will us a different resultTransformer. In my case I had a one to many relationship that was spec'd as
orders(lazy:false, fetch:"join")
the fetch as join told gorm to do a large query and then reduce the set of data after the max offset was applied.
for more reading look into the following:
agination-with-hibernate-criteria-and-distinct-root-entity
sorting-and-pagination-with-hibernate-criteria-how-it-can-go-wrong-with-joins