Grails hasOne Relationship没有belongsTo

时间:2018-05-18 22:36:14

标签: hibernate grails gorm

当浏览文档以处理没有belongsTo的hasOne关系时,它会抛出错误

  

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

它只是一个例子,在我的用例中如果我删除了鼻子我不应该删除face.So如何使它工作而不使用belongsTo?

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

1 个答案:

答案 0 :(得分:1)

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

class Face {
  Nose nose
}

class Nose {
  Face face
}

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