【发布时间】:2011-07-15 11:52:41
【问题描述】:
我只是想进行分页,但直到现在我都无法做到。我有 2 个域类和一对多关系。
class User {
static hasMany = [contacts:Contact]
}
class Contact {
static belongsTo = [ user : User ]
}
我有 20 个联系人。
当我尝试进行这样的查询时:
def maxResult = 20
def startIndex = 0
def contacts = Contact.findAllByUser(user, [max:maxResult, offset:startIndex])
它不工作。查询正在工作,但使用 gorm 的分页不起作用。结果只有 1 个联系人对象。
当我尝试过时;
def startIndex = 0
def contacts = Contact.findAllByUser(user, [offset:startIndex])
结果是 20 个联系人对象,但是当我尝试使用不同的 startIndex 值时,它也不起作用。对于 startIndex = 5,结果也是 20 个接触对象。
有没有人对此有任何想法。也许我做错了什么,也许是gorm的问题。我还没有找到答案。感谢您的回答。
【问题讨论】:
标签: grails pagination grails-orm