-1
請幫我一下。我是Grails新手。我已閱讀grails doc,但沒有找到我的問題的答案。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);
這是正確的實現?
你的問題是什麼? – j4y
我已經解決了我的問題 – Klesk