我想在父对象的可移动对象上自动删除子对象。
例如,我有Car和Engine类型。汽车具有属性Engine。删除Car对象后,应自动删除绑定到此Car的Engine对象。
谢谢,伙计们
答案 0 :(得分:2)
使用“ partOf”修饰符:
<itemtype code="Car" ...>
...
<attributes>
...
<attribute qualifier="engine" type="Engine">
<persistence type="property" />
<modifiers partof="true" />
</attribute>
</attributes>
</itemtype>
也可以与关系一起使用:
<relation code="CarToEngineRelation"...>
<sourceElement type="Car" ...>
</sourceElement>
<targetElement type="Engine" ...>
<modifiers partof="true"/>
</targetElement>
</relation>
答案 1 :(得分:-1)
@Johannes很好地树立了榜样。
让我详细说明
PartOf修饰符用于定义父对象和子对象之间的聚合关系。为了更好地解释它,我会说PartOf用于定义级联删除。当我们删除父对象时,其所有子对象(partOf)将被自动删除。
您可以借助修饰符标签在属性或关系中定义它。喜欢
<itemtype code="User"
extends="Principal"
jaloclass="de.hybris.platform.jalo.user.User"
autocreate="true"
generate="true">
<deployment table="Users" typecode="4" propertytable="UserProps"/>
<attributes>
...
...
<attribute autocreate="true" qualifier="addresses" type="AddressCollection">
<modifiers partof="true"/>
</attribute>
<attribute autocreate="true" qualifier="carts" type="CartCollection">
<modifiers partof="true"/>
</attribute>
</attributes>
</itemtype>
如果我们删除用户,则其所有地址和购物车也会被删除。