为什么通过枚举类型动态= "false"设置为假?



为什么通过enumtype dynamic="false"设置为false?我什么时候应该将其设置为"true"

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

使用Hybris Enumtype,您可以选择定义静态枚举或动态枚举。静态(dynamic =" false"(的意思是,枚举仅包含定义的元素。在运行时,您将永远无法在枚举中添加元素。当您使用动态枚举(Dynamic =" True"(时,这是不同的。通过动态枚举,您可以在运行时添加值。因此,如果您希望枚举是静态的,请使用dynamic =" false"。如果要在运行时添加值,请使用dynamic =" true"。

我想我很难找到答案:

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).

简单地说,我可以说静态枚举(dynamic="false",默认值(被生成为Java枚举。在哪个值列表中,只能通过更改items.xml在汇编时间更改。在动态枚举(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 Enum

的信息

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

如果dynamic ="true",则用作hybris_Enum(即,您可以在运行时添加其他枚举值Types(。

最新更新