zl程序教程

您现在的位置是:首页 >  其它

当前栏目

primary key in ABAP and Hybris

in and Key ABAP PRIMARY Hybris
2023-09-14 09:02:49 时间

ABAP

在这里插入图片描述

Hybris

it is necessary to use attribute unique to decorate one field, which is defined in schema items.xsd:

<xs:attribute name="unique" type="xs:boolean" use="optional">
            <xs:annotation>
                <xs:documentation>If 'true', the value of this attribute has to be unique within all instances of this type. If there are multiple attributes marked as unique,
        then their combined values must be unique. Will not be evaluated at jalo layer, if you want to manage the attribute directly using jalo layer you have to               ensure uniqueness manually. Default is 'false'.
      </xs:documentation>
            </xs:annotation>
 </xs:attribute>

See one example:

``xml











The above example fails to work as expected, in that case code1 and code2 are defined as unique separately, but don't constitute as composite key.

# solution

```xml
<itemtype code="xxx" 
     <deployment table="xxx" typecode="30001" />
                <attributes>
                    <attribute qualifier="code1" type="String" generate="true">
                        <persistence type="property"></persistence>
                        <modifiers read="true" write="true" search="true" optional="false"  />
                    </attribute>
                    <attribute qualifier="code2" type="String">
                        <modifiers read="true" write="true" search="true" optional="false" />
                        <persistence type="property" />
                    </attribute>
          <indexes>
                    <index name="ProductSalesOrg" unique="true">
                        <key attribute="product"/>
                        <key attribute="salesOrg"/>
                    </index>
              </indexes>
</itemtype>