开发者

Order by children property in Grails

开发者 https://www.devze.com 2022-12-10 17:56 出处:网络
Is it possible to create a criteria that lists all objects sorted by sope property of their children?

Is it possible to create a criteria that lists all objects sorted by sope property of their children? For example:

class Post {
    User owner
}

Post.withCriteria {
    order('owner.registerDate', 'asc')
}

It fails with message: Error 500: org.开发者_如何学编程hibernate.QueryException: could not resolve property: owner.registerDate of: Post

What is the right way to do it?

Thanks in advance.


this isn't supported by grails out of the box but there's a plugin that enables this feature:

See http://grails.org/plugin/gorm-labs


It is possible doing this:

Post.withCriteria {
    owner{
        order('registerDate', 'asc')
    }
}
0

精彩评论

暂无评论...
验证码 换一张
取 消