0

为什么按 enumtypedynamic="false"设置为 false?我应该什么时候设置它"true"

<enumtype code="MyEnumType" generate="true" autocreate="true" dynamic="false">
    <value code="NONE" />
    <value code="ONE" />
</enumtype>
4

4 回答 4

2

使用 hybris 枚举类型,您可以选择定义静态枚举或动态枚举。Static (dynamic="false") 表示枚举仅包含已定义的元素。在运行时,您将永远无法向枚举添加元素。当您使用动态枚举 (dynamic="true") 时,情况会有所不同。使用动态枚举,您可以在运行时添加值。因此,如果您希望枚举是静态的,请使用 dynamic="false"。如果要在运行时添加值,请使用 dynamic="true"。

于 2018-04-26T10:33:00.843 回答
1

我想我很难找到答案:

INSERT_UPDATE ManufacturerName;code[unique=true];name[lang=de];name[lang=en]

    ,,,,Exception : line 9: cannot create ManufacturerName with values ItemAttributeMap[ registry:  null, type: <null>, data: {code=00000023344, name={8796093054536->de=3D , 8796093054536->en=3D }} ] due to [de.hybris.platform.servicelayer.interceptor.impl.EnumerationValidator@197d511d]:Enum type ManufacturerName is not dynamic - can not create new enum value 00000023344. If you want to add a new value to this type you have to define the enum type as non dynamic at items.xml (needs system update afterwards).
于 2018-04-26T08:54:30.850 回答
0

如果dynamic ="false",则表示它充当java_Enum(无法修改)。

如果dynamic ="true",它充当hybris_Enum(即,您将能够Types在运行时通过 hac 添加额外的 Enumeration 值)。

于 2020-08-03T17:13:17.703 回答
0

简单来说,我可以说静态枚举(dynamic="false",默认值)是作为 Java 枚举生成的。其中值列表只能在编译期间通过更改 items.xml 来更改。对于动态 enum( dynamic="true"),我们可以在运行时使用 hmc 或 Impex 更改(添加/删除)它的值。


静态枚举:

    <enumtype code="FixedValueType" autocreate="true" generate="true">
        <value code="value1"/>
        <value code="value2"/>
    </enumtype>

动态枚举:

    <enumtype code="OrderStatus" autocreate="true" generate="true" dynamic="true">
        <value code="CREATED"/>
        <value code="ON_VALIDATION"/>
        <value code="COMPLETED"/>
        <value code="CANCELLED"/>
    </enumtype>

更多关于 hybris 枚举

于 2018-04-26T13:32:38.983 回答