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 order by b.dateCreated desc", [max: max, offset: offset])
But what I want is:
def books = Book.findAll("from Book as b where b.approved=true", [sort: 'dateCreated', order: 'desc', max: max, offset: offset])
This does not work. How do I have to rewrite this?
Using "findAllBy" because it supports sort and order.
def results = Book.findAllByTitle("The Shining",
[max: 10, sort: "title", order: "desc", offset: 100])
Click here for details.
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With