I have a domain which call party and has many invitees. party.invitees give me a the set collection of the invitees. I want to get only some of the invitees so I try do do the followinf in my service.
partInvitees= event?.invitees?.findAll{[offset: 3,max: 8]}
It doesn't give the correct result. It gives me all the invitees instead only the specific I have asked.
You could use the GORM
list()
method to get the entire collection for a domain class. If you want only a subset of the collection you could uselist()
with some parameters.If your domain class is named
Invite
, you should useInvite.list(max: 8, offset: 3, sort: "id", order: "asc")
to get the subset described in your question. Keep in mind that different sort/order params could give you different results.See the
list()
orlistOrderBy()
documentation for more information.If you want
Invites
only for a specificEvent
you should read the Deigote answer.