【问题标题】:Grails hasOne Relationship without belongsToGrails hasOne 没有 belongsTo 的关系
【发布时间】:2018-05-18 22:36:13
【问题描述】:

当通过文档处理没有 belongsTo 的 hasOne 关系时,它会引发错误

hasOne 属性 [Face.nose] 不是双向的。指定关系的另一方!。

这只是一个例子,在我的用例中,如果我删除鼻子,我不应该删除面部。那么如何在不使用 belongsTo 的情况下使其工作?

class Face {
..
static hasOne = [nose: Nose]
}
class Nose {
Face face
}

【问题讨论】:

    标签: hibernate grails grails-orm


    【解决方案1】:

    我认为您的路径是不使用hasOne 关键字。

    class Face {
      Nose nose
    }
    
    class Nose {
      Face face
    }
    

    两者都可以独立存在,但都可以相互引用。

    【讨论】:

      猜你喜欢
      • 2014-07-17
      • 1970-01-01
      • 2020-05-16
      • 1970-01-01
      • 1970-01-01
      • 2013-10-05
      • 1970-01-01
      • 2017-11-06
      • 2016-02-29
      相关资源
      最近更新 更多