【问题标题】:Grails realization relationships [closed]Grails 实现关系
【发布时间】:2012-11-17 07:50:07
【问题描述】:

你能帮帮我吗?我是 Grails 的新手。我已阅读 grails 文档,但没有找到问题的答案。

类客户: 封装测试

    class Customer {
        int points
        static hasMany = [pr:Product]
        List pr;
        static constraints = {
        }
    }

类产品:

package test
class Product {
    String question
    int points
    static belongsTo = [c:Customer]
    static constraints = {
    }

正如我们所见,存在一对多的关系。 然后我想向一位客户添加很多产品:

    def cust = new Customer()
    def pr = new Product();
    cust.pr=new ArrayList();
    cust.pr.add(pr);

这是正确的认识吗?

【问题讨论】:

    标签: grails orm groovy


    【解决方案1】:

    默认情况下,当您使用 GORM 定义关系时,它是 java.util。

    Answer

    【讨论】:

      猜你喜欢
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 2013-12-20
      • 1970-01-01
      • 1970-01-01
      相关资源
      最近更新 更多