任何人都可以帮助我。我有两个域名。
Class Parent{
static hasMany = [child: Child];
}
Class Child{
}
在数据库中有20条记录。我想只刷新10页而不刷新页面。所以我使用远程分页之类的。
gsp代码
<util:remotePaginate controller="Parent" action="show"
total="${parentList.size()}"
update="updatedListId" max="10" pageSizes="[10, 20, 50,100]"/>
在控制器中,我写了像。
def parent =Parent.get(1);
def parentList = parent.getChild();
我尝试过这个,但它没有用。
def childs = Child.findAllByParent(parent, [max: 10])
它提供了所有记录,但我需要在这里只获得10条记录。我设置params max value并将其作为参数传递但不起作用。
请帮帮我。 谢谢
答案 0 :(得分:0)
您可以通过HQL获取联接中的孩子:
Child.executeQuery("select c from Parent p join p.childs c where p=:p", [p:p, max:10])
答案 1 :(得分:0)
您是否尝试过where
查询?
// Parent.groovy
class Parent{
static hasMany = [ children: Child ]
}
// Where query in controller/service
Parent.where { id == 1L }.children.list(max: 10)