There are two subtly different, but distinct ways to model a One-to-Many relationship in GORM, each with some rather interesting implications.
Method One:
1:class Book{
2: String title
3: static belongsTo = Author
4:}
5:
6:class Author {
7: String name
8: static hasMany = [books: Book]
9:}
This method results in the schema:
Furthermore, the following applys:
- An additional "link" table (author_book) will be created in the database.
- A books property will be available on Author
- There is no direct way of querying the reverse of the relationship. i.e. no straightforward way to lookup an Author if you're holding a Book object.(See this post for a solution)
Method Two:
1:class Book{
2: String title
3: static belongsTo = Author
4: Author author
5:}
6:
7:class Author {
8: String name
9: static hasMany = [books: Book]
10:}
This method results in the schema:
- An additional column called author_id will be created on the Book table in the database
- No "link" table will be created in the database
- It is possible to query both the forward and reverse relationship by refering to the Books.author and Author.books properties respectively
FIN.

