tags:

views:

80

answers:

2

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')
}
+3  A: 

I believe you'd want to use something like:

...
firstResult(offset)
...

As I recall, the Criteria DSL corresponds closely to the Hibernate Criteria class.

ig0774
A: 

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)
}
leebutts