我有一个使用HQL的列表方法。如何将分页和排序参数添加到此查询中?Grails:将排序和分页添加到自定义HQL查询
def list = {
def termList
log.info "Getting terms for product: $params.productId"
params.max = 10
def p = Product.get(params.productId)
if (p) {
log.info "Product found: $p.name"
termList = Term.executeQuery("select distinct t from Term as t join t.definitions def join def.definitionProducts dp where dp.product=?",
p)
} else {
log.info "No Product found"
termList = Term.list(params)
}
log.info "Terms found: $termList.size"
[ termInstanceList: termList, termInstanceTotal: termList.size]
}
这个答案ISN”完全正确。像下面的答案状态一样,您不能使用executeQuery进行排序和排序。见http://jira.codehaus.org/browse/GRAILS-1200。 – 2009-10-05 05:37:56