Grails实现关系

Grails实现关系,grails,orm,groovy,Grails,Orm,Groovy,你能帮帮我吗。我是圣杯新手。我已经阅读了GrailsDoc,但没有找到问题的答案 类别客户: 包装试验 class Customer { int points static hasMany = [pr:Product] List pr; static constraints = { } } 类别产品: package test class Product { String question

你能帮帮我吗。我是圣杯新手。我已经阅读了GrailsDoc,但没有找到问题的答案

类别客户: 包装试验

    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);

这是正确的实现吗?

默认情况下,当您定义与GORM的关系时,它是一个java.util