【发布时间】:2010-09-19 16:47:05
【问题描述】:
通常设置一对多关联很容易。举个例子:
class Author {
String firstName
String lastName
static hasMany = [books: Book]
static constraints = {
books(nullable: true)
}
}
class Book {
String title
Author author
Publisher publisher
static constraints = {
author(nullable: true)
publisher(nullable: true)
}
}
但是,如果我在根本不知道 Book 的情况下设置了 Author 域,则最初没有指定 static hasMany = [books: Book]。后来想加一个Book域,想把static hasMany = [books: Book]加到Author中。我可以用插件做到这一点吗?如果有,怎么做?
谢谢。
【问题讨论】:
-
是什么阻止您更新 Author 类并添加到 hasMany 书籍中?
标签: plugins grails groovy metaprogramming