GrailsLearner
GrailsLearner

Reputation: 525

Grails hasOne Relationship without belongsTo

When going through documentation to work on hasOne relationship without belongsTo it throws an error

hasOne property [Face.nose] is not bidirectional. Specify the other side of the relationship!.

Its just an example, in my usecase if i delete the nose i should not delete the face.So how to make it work without using belongsTo?

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

Upvotes: 0

Views: 166

Answers (1)

Trebla
Trebla

Reputation: 1174

I think your path here is to not use the hasOne keyword.

class Face {
  Nose nose
}

class Nose {
  Face face
}

Either can exist independently of the other, but both have references to each other.

Upvotes: 1

Related Questions