Grails hasOne and hasMany same domain

后端 未结 2 1561
予麋鹿
予麋鹿 2021-01-07 15:18

I have domain like this:

class Team {
 hasOne [leader: Person]
 hasMany [member: Person]
}

class Person {
 belongsTo [team: Team]
}

But wh

2条回答
  •  无人及你
    2021-01-07 15:50

    I figured that, what I need is

    class Team {
     belongsTo [leader: Person]
     hasMany [member: Person]
    }
    
    class Person {
     belongsTo [team: Team]
    }
    

    so that the Team table can have the desired "leader" reference back to Person.

提交回复
热议问题