如何在grails中建立两个域类之间的关系。我已经有一个来自插件的域类(spring安全插件),我想将USER域类从插件链接到Profile域类。最好的方法是什么?
答案 0 :(得分:6)
有关概述,请参阅GORM documentation。对于一个一对一的关系,我假设一个配置文件,你可以简单地执行以下操作:
class User {
Profile profile
}
class Profile {
// only needed if you need to refer to user from the Profile instance
static belongsTo = [user:User]
}