[英]Domain classes in grails
How to make relationship between two domain classes in grails . 如何在Grails中建立两个域类之间的关系。 I already have one domain class from the plugin (spring security plugin) and i want to link USER domain class from plugin to the Profile domain class .
我已经从插件(spring security插件)中获得了一个域类,并且我想将USER域类从插件链接到Profile域类。 What is the best way to do it?
最好的方法是什么?
See the GORM documentation for a good overview. 有关良好的概述,请参见GORM文档 。 For a one-to-one relationship as I assume a profile would be, you could simply do the following:
对于我认为是一对一的关系,您可以简单地执行以下操作:
class User {
Profile profile
}
class Profile {
// only needed if you need to refer to user from the Profile instance
static belongsTo = [user:User]
}
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.