I want to integrate sort, order, max and offset in a findAll query. The following works fine:
def books = Book.findAll(\"from Book as b where b.approved=true ord
I am assuming you are calling fetching the list of books in a controller or a service class.
If you are calling this from a controller action, then a magic variable "params" is already available to you. For example, if you request the page as follows
book/list?max=10&offset=2
then "params" will already have those values mapped automagically.
You can add more items to the params map as follows
params.sort = "dateCreated"
params.order = "desc"
Once you have build your params as desired, then you can use Grails dynamic query as follows
def books = Book.findAllByApproved(true, params)
// use "books" variable as you wish