Each book can have many authors. And each author can author many books.
class Book {
static belongsTo = Author
static hasMany = [authors:Author]
}
class Author {
static hasMany = [books:Book]
}
Now when can I do:
def book = Book.get(id)
def authors = book.authors
Now I am thinking I should be able to take each author and get the books he is associated with:
authors.each {
it.books
}
You see now it would get recursive (leading to stackoverflow). Does anyone know how it exactly works, when it is doing eager fetch?