Reputation: 783
I have a list of integer representing ids.
I want to use getAll to retreive and return all instances to GSP and I would like also to use pagination (offset, max).
How can I do that
MyClass.getAll([1, 2, 3,...])
Thank you for your help
Upvotes: 0
Views: 421
Reputation: 1107
As dmahapatro pointed out you can also use executeQuery. This gives you a lot of control of the query to run and the params to pass in.
def users = User.executeQuery("from User u where u.id IN (1,2,3)",[max:2,offset:0])
Upvotes: 1
Reputation: 50255
You can use findAllBy*
or drill down using an HQL with executeQuery
. I think the former approach will be simpler since only ids
are involved.
MyClass.findAllByIdInList([1, 2, 3, ....]*.toLong(), [max: 5, offset: 1])
Upvotes: 3