grails中的域类

Kul*_*ngh 0 grails groovy spring spring-security

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

Kal*_*see 6

有关概述,请参阅GORM文档.对于我假设配置文件的一对一关系,您可以简单地执行以下操作:

class User {
    Profile profile
}

class Profile {
    // only needed if you need to refer to user from the Profile instance
    static belongsTo = [user:User] 
}
Run Code Online (Sandbox Code Playgroud)