grails中的域类

时间:2011-11-07 21:15:54

标签: spring grails groovy spring-security

如何在grails中建立两个域类之间的关系。我已经有一个来自插件的域类(spring安全插件),我想将USER域类从插件链接到Profile域类。最好的方法是什么?

1 个答案:

答案 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] 
}