1

我对包含文档 ID 参考的 impex 有疑问。

来自文档:“特别是对于导入 partOf 项目值,有必要通过通常的唯一列技术以外的方式引用这些项目,因为 partOf 项目通常不提供唯一键,而仅将其封闭的父项作为外键。”

*items.xml 中的项目(仅最重要的部分)

<itemtype code="A" autocreate="true" generate="true" abstract="true"/>

<itemtype code="B" autocreate="true" generate="true" extends="A">
    <deployment table="btable" typecode="20115" />
    <attributes>
        <attribute qualifier="code" type="java.lang.Integer" autocreate="true" generate="true">
         <persistence type="property"/>
         <modifiers optional="false"/>
    </attribute>
</attributes>
</itemtype>

<itemtype code="C" autocreate="true" generate="true">
    <deployment table="ctable" typecode="20117" />
    <attributes>
        <attribute qualifier="code" type="java.lang.String" autocreate="true" generate="true">
            <persistence type="property"/>
            <modifiers optional="false" unique="true"/>
        </attribute>
        <attribute qualifier="test" type="A" autocreate="true" generate="true">
            <persistence type="property"/>
            <modifiers optional="false" partof="true"/>
        </attribute>
    </attributes>
</itemtype>

英派克代码:

INSERT B;code;&docIdRef
;1;docId

INSERT_UPDATE C;code[unique=true];test(&docIdRef)
;uniqueCode;docId

错误信息:

 cannot create C with values ItemAttributeMap[ registry:  null, type: <null>, (...) due to [de.hybris.platform.servicelayer.interceptor.impl.MandatoryAttributesValidator@3b777877]:missing values for [test] in model C

当我从 'test' 属性(C 类)中删除 'partof' 修饰符时,一切正常。

我想知道如果我想保留“partof”修饰符,impex 应该是什么样子。

4

3 回答 3

1

使用partOf时必须参考partOf使用所有者。

所以它确实:

INSERT B;owner(C.code);&docIdRef
;uniqueCode;docId

INSERT_UPDATE C;code[unique=true];test(&docIdRef)
;uniqueCode;docId

您不需要分配B标识符,只需要引用所有者即可。

于 2017-02-07T09:03:54.380 回答
0

既然你已经提到partof="true"你不能分配 type 的引用A。您只能创建一个新实体。

检查 OOTBAbstractOrder2AbstractOrderEntry关系,他们提到partof="true"AbstractOrderEntry你不能引用任何其他AbstractOrderEntryOrder. 您可以随时创建新条目。

也可以查看 HMC 网站

在此处输入图像描述

你可以看到这里没有+ Add Entry可用的按钮。倒数是可能的。

于 2017-02-07T05:18:55.320 回答
0

如果您确定您的数据是正确的,您可以使用 [forceWrite=true] 修饰符或旧模式跳过服务层验证。

您还应该确保此配置是您真正需要的。将 optional 设置为 true 或将 partOf 设置为 false 或提供默认值也应该可以解决问题。

于 2017-02-06T17:53:50.087 回答