私はとても単純に見える何かをしようとしています。Userクラスがあり、2人のUsersに一致するGameクラスがあります。これは簡単です:
class User {
String username
static hasMany = [games:Game]
}
class Game {
User player1
User player2
}
これを実行すると、
Caused by GrailsDomainException: Property [games] in class [class User] 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 [user] or use the 'mappedBy' static to define the property that the relationship is mapped with. Example: static mappedBy = [games:'myprop']
そこで、掘り下げてmappedByを見つけ、コードを次のように変更しました。
class User {
String username
static hasMany = [games:Game]
static mappedBy = [games:'gid']
}
class Game {
User player1
User player2
static mapping = {
id generator:'identity', name:'gid'
}
}
今私は得る
Non-existent mapping property [gid] specified for property [games] in class [class User]
私は何が間違っているのですか?