bezmax
bezmax

Reputation: 26122

Order by children property in Grails

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.

Upvotes: 3

Views: 1389

Answers (2)

quindimildev
quindimildev

Reputation: 1280

It is possible doing this:

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

Upvotes: 3

Siegfried Puchbauer
Siegfried Puchbauer

Reputation: 6539

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

Upvotes: 3

Related Questions