请你帮助我好吗。我是 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);
这是正确的认识吗?