Warning: file_get_contents(/data/phpspider/zhask/data//catemap/3/wix/2.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181
Grails GORM有许多相同的类型?_Grails_Gorm - Fatal编程技术网

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或在关联和个人之间使用正确的模型为您的收藏/关联建模。