I have the following:
class Match{
Team localTeam
Team visitingTeam
}
class Team{
static hasMany = [matches: Match]
}
that throws: Error loading plugin manager: Property [matches] in class [class myapp.Team] is a bidirectional one-to-many with two possible properties on the inverse side. Either name one of the properties on other side of the relationship [team] or use the 'mappedBy' static to define the property that the relationship is mapped with. Example: static mappedBy = [matches:'myprop']
So, I use 'mappedBy':
class Team{
static hasMany = [matches: Match]
static mappedBy = [matches: localTeam, matches: visitingTeam]
}
but, by doing this, when I get a team from db, matches Set only contains the matches where the team is the visiting team, meaning it only maps matches to the visitingTeam.
If I code de following:
class Team{
static hasMany = [matches: Match]
static mappedBy = [matches: localTeam]
}
It only maps matches of the localTeam.
Is there a way to map both matches (when the team is local and when it is the visitor) to the Team?