Grails GORM有许多相同的类型?
是否可能有一个域类,其中多个域类具有许多相同类型的关系,而对象保存在单独的表中Grails GORM有许多相同的类型?,grails,gorm,Grails,Gorm,是否可能有一个域类,其中多个域类具有许多相同类型的关系,而对象保存在单独的表中 class Child { String description static belongsTo = [parent: Parent] } class Parent { static hasMany = [childAssociation1 : Child, childAssociation2 : Child] } 当我创建一个子对象并将其添加到父对象中的一个对象时,它有许多关联,然后从
class Child {
String description
static belongsTo = [parent: Parent]
}
class Parent {
static hasMany = [childAssociation1 : Child, childAssociation2 : Child]
}
当我创建一个子对象并将其添加到父对象中的一个对象时,它有许多关联,然后从另一个对象查询它,它将同时出现在这两个对象中
i、 e.当我添加时,使用:
parent.addToChildAssociation1(child)
然后,child是parent.addToChildAssociation2的成员
这是预期的行为吗 这是因为你的财产。这是预期的行为,因为它通过两个关联满足关系。请删除belongsTo或在关联和个人之间使用正确的模型为您的收藏/关联建模。