【发布时间】:2014-04-25 14:09:22
【问题描述】:
在 Grails 中,单向 1:M 关系默认使用连接表。见:http://grails.org/doc/2.3.7/guide/GORM.html#oneToMany
这是为什么?
还有没有办法阻止这种行为。
谢谢
【问题讨论】:
-
您找到想要的东西了吗?答案有帮助吗?
标签: grails orm grails-orm
在 Grails 中,单向 1:M 关系默认使用连接表。见:http://grails.org/doc/2.3.7/guide/GORM.html#oneToMany
这是为什么?
还有没有办法阻止这种行为。
谢谢
【问题讨论】:
标签: grails orm grails-orm
为了避免单向 1:M 中的连接表,必须在父级中为关联指定外键:
class Book {
static hasMany = [authors: Author]
static mapping = {
authors column: 'BOOK_AUTHOR_ID'
}
}
【讨论】: