views:

72

answers:

1

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.

+2  A: 

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

Siegfried Puchbauer
Hm, strange. I've just found this code working. Am I using it right or am I really lucky to get it working way I need it? Post.withCriteria { owner { order('registerDate', 'asc') } } This call gives me a list of all posts sorted by owner.registerDate... Maybe it's some new Grails 1.1.1 feature, while plugin makes it work for some <1.1 version?
Max