如果我有两个域如下
class Author {
static hasMany = [books: Book]
String name
}
class Book {
static belongsTo = [author: Author]
String color
}
如何同时为作者添加多本书?
像下面:
def book1 = new Book(color: "white")
def book2 = new Book(color: "black")
def books = []
books << book1
books << book2
def author = new Author(name: "John Doe").addToBooks(books).save()