gorm / grails sort hasMany children items

时间:2015-10-11 10:12:40

标签: hibernate grails hql gorm

class A {
    hasMany = [b: B]
} 
class B {
    int type
    String title
    belongsTo = [a: A]
}

有没有办法getlist类型A,其类型B的集合按类型排序,另一个按标题排序?< / p>

1 个答案:

答案 0 :(得分:0)

试试这段代码:

def listOfA = A.withCriteria {
    eq "id", 123456
    b {
        and {
            order "type", "desc"
            order "title", "desc"
        }
    }
}