开发者

How to set offset in GORM when using createCriteria?

开发者 https://www.devze.com 2022-12-30 00:02 出处:网络
I\'m just wondering if it\'s possible for \'createCriteria\' to specify the paginateParams (i.e. offset) similar to dynamic finder (findAll, etc.)

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

精彩评论

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

关注公众号