【问题标题】:Unidirectional 1:M relationship uses join table by default单向 1:M 关系默认使用连接表
【发布时间】:2014-04-25 14:09:22
【问题描述】:

在 Grails 中,单向 1:M 关系默认使用连接表。见:http://grails.org/doc/2.3.7/guide/GORM.html#oneToMany

这是为什么?

还有没有办法阻止这种行为。

谢谢

【问题讨论】:

  • 您找到想要的东西了吗?答案有帮助吗?

标签: grails orm grails-orm


【解决方案1】:

为了避免单向 1:M 中的连接表,必须在父级中为关联指定外键:

class Book {

    static hasMany = [authors: Author]

    static mapping = {
        authors column: 'BOOK_AUTHOR_ID'
    }
}

【讨论】:

    猜你喜欢
    • 2018-12-05
    • 2018-08-02
    • 2011-09-10
    • 1970-01-01
    • 1970-01-01
    • 2020-08-17
    • 2021-09-11
    • 2014-01-22
    • 1970-01-01
    相关资源
    最近更新 更多