Reputation: 2063
I'm just wondering if it's possible for 'createCriteria' to specify the paginateParams (i.e. offset) similar to dynamic finder (findAll, etc.)
Note that this code is not working since 'offset' is not documented in http://www.grails.org/doc/1.2.1/ref/Domain%20Classes/createCriteria.html
def c = SnbrItemActDistance.createCriteria()
def results = c.list {
eq('iid', newsId)
ge('distance', cap)
maxResults(count)
offset(offset)
order('distance', 'desc')
}
Upvotes: 3
Views: 5055
Reputation: 4882
You can also pass in a map to list e.g.
def c = SnbrItemActDistance.createCriteria()
def results = c.list(max:count, offset:offset) {
eq('iid', newsId)
ge('distance', cap)
}
Upvotes: 2
Reputation: 41277
I believe you'd want to use something like:
...
firstResult(offset)
...
As I recall, the Criteria DSL corresponds closely to the Hibernate Criteria class.
Upvotes: 7