0
在Grails中创建一个简单的采购订单应用程序,其中包含Category(例如:TV,Video ...),Brand和Item。品牌是相关的(hasMany)类别,例如索尼制造视频和电视。如何将多个对象添加到Groovy中的对象属性? ---在Bootstrap.groovy
里面BootStrap.groovy中,我要做到以下几点:
Brand jvc = new Brand(name:"JVC")
Brand sony = new Brand(name:"Sony")
Brand samsung = new Brand(name:"Samsung")
Category tv = new Category(name:"Television")
Category video = new Category(name:"Video")
Category laptop = new Category(name:"Laptop")
sony.categories.(tv) ----> These methods are wrong
sony.addCategory(video) ----> These methods are wrong
sony.addCategory(laptop)
如何将品牌多个类别相关联?注意我尝试了很多不同的方法模板,但都没有成功Brand类中的属性是静态的hasMany [categories:Category]。