开发者

How to set offset in GORM when using createCriteria?

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)
    offs开发者_Python百科et(offset)
    order('distance', 'desc')
}


I believe you'd want to use something like:

...
firstResult(offset)
...

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


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

上一篇:

下一篇:

精彩评论

暂无评论...
验证码 换一张
取 消

最新问答

问答排行榜