[英]gorm/grails sort hasMany children items
class A {
hasMany = [b: B]
}
class B {
int type
String title
belongsTo = [a: A]
}
Is there any way to get
or list
type A
, which would have collections of type B
sorted in one case by type, in another by title? 是否有任何方法可以get
或list
类型A
,其中类型B
集合在一种情况下按类型排序,在另一种情况下按标题排序?
Try this code: 试试这个代码:
def listOfA = A.withCriteria {
eq "id", 123456
b {
and {
order "type", "desc"
order "title", "desc"
}
}
}
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.