Reputation: 16586
I am having problems defining one-to-one and one-to-many relationships with domain classes. I have the following domain classes
class Team {
static hasMany = [players: Player]
static hasOne = [coach: Coach]
}
class Person {
String name
}
class Player extends Person {
}
class Coach extends Person {
}
So my questions are:
1- Do I need to declare a variable team
in Player and in Coach ?
2- Do I need to declare a belongsTo
as well?
3- Considering the above classes, is it preferable to use hasOne?
Thank you.
Upvotes: 2
Views: 2952
Reputation: 1717
There is a slight mistake with leebutt's answer.
Upvotes: 2
Reputation: 4882
cheers
Lee
Upvotes: 1