Grails上的继承和数据绑定
我在对继承模型使用数据绑定时遇到问题。这是我的密码:Grails上的继承和数据绑定,grails,inheritance,data-binding,Grails,Inheritance,Data Binding,我在对继承模型使用数据绑定时遇到问题。这是我的密码: class Member { int age static belongsTo = [Family] static constraints = {} } class Parent extends Member { String name static constraints = {} } class Family { String name List members static h
class Member {
int age
static belongsTo = [Family]
static constraints = {}
}
class Parent extends Member {
String name
static constraints = {}
}
class Family {
String name
List members
static hasMany = [members: Member]
static constraints = {}
}
def test(){
def bindingMap = [name: 'toto', members:[[age: 18, name: '1'],[age: 18]]]
def family = new Family()
family.properties = bindingMap
family.save(flush: true)
def get = Family.get(family.id)
// here family only contains Member and no Parent, as expected...
}
正如您所看到的,使用这段代码,我无法创建具有数据绑定的父级。
有人有主意吗
谢谢