私はbelongstoにマップ表記を使用する傾向があるので、私はこのようにそれをします:
class Status {
String text
static belongsTo = [author: Person]
}
その後、クエリは簡単です:
def messages = Status.findAllByAuthor(currentPerson)
hasmanyの人に双方向を追加した場合:
class Person {
static hasMany = [messages: Status]
}
これを行うこともできます:
def messages = currentPerson.messages