【发布时间】: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);
这是正确的认识吗?
【问题讨论】: