我有 2 个具有 belongsTo 关联的域类
class Teacher {
String name
String department
}
class Address {
String line1
String line2
// Teacher teacher //this line is commented.
static belongsTo = [teacher: Teacher]
static constraints = {
}
}
- 当我让地址属于老师时,我得到了什么好处
- 我需要在地址类中声明教师对象引用吗(参见教师类中的注释行)