I have the following Grails classes and relationships:
class Book {
static hasMany = [articles: Article]
}
class Article {
static belongsTo = [book: Book]
}
Can I do the following to get a correct relationship being set?
def book = // some book instance
def article = new Article()
article.book = book
article.save()
Is the former same as the following?
def book = // some book instance
def article = new Article()
book.addToArticles(article)
book.save()
you can turn on sqllog in DataSource.config and compare result sql. belongsTo - saves and deletes will cascade from Book to the associated Article.