古典的な著者/本のパターン (grails 2.2.0) を使用します。
class Author {
static hasMany = [books: Book]
}
class Book {
static belongsTo = [author: Author]
}
子インスタンスを作成すると、親セットが更新されないのはなぜですか:
Author author = new Author().save()
Book book = new Book(author: author).save()
assert author.books.size == 1 // FAIL
author オブジェクトはデータベースで変更されないため、なぜ author.addToBooks(book).save() を使用する必要があるのですか ???