【问题标题】:Domain classes in grailsgrails 中的领域类
【发布时间】:2011-12-23 23:17:04
【问题描述】:

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

【问题讨论】:

    标签: spring grails groovy spring-security


    【解决方案1】:

    请参阅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] 
    }
    

    【讨论】:

      猜你喜欢
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 2011-09-14
      • 1970-01-01
      • 1970-01-01
      • 2014-02-24
      • 1970-01-01
      相关资源
      最近更新 更多