Sign up ×

I am using grails and I am having trouble finding the appropriate syntax for joining and ordering across different domains. For example, given the example below, I would like to retrieve a page of book data sorted by title for all authors that come from (eg) London. I have a preference for using createCriteria, but will use another technique if needed.

class Location {
    String city
    static hasMany = [authors: Author]

class Author {
    String name
    static belongsTo = [location: Location]
    static hasMany = [books: Book]

class Book {
    String title
    static belongsTo = [author: Author]

To clarify, what I want to achieve would be to get a list of book domain classes that is equivalent to something like

Select Book.title
From Book
Inner Join Author
On = Book.authorName
Inner Join Location
On = Author.homeCity
Where = 'London'
Order by Book.title


share|improve this question

1 Answer 1

up vote 1 down vote accepted

For creating more complex database queries you can use [criteria objects][1] or [Hibernate Query Language (HQL)][2]. Second way is more powerful but less comfortable.

[1]: Criteria

[2]: Hibernate Query Language (HQL)

share|improve this answer

Your Answer


