cancel
Showing results for 
Search instead for 
Did you mean: 

Trial of Redeclaration

0 Kudos
223

I have created two different yempty extensions named 'letsTravel' and 'examResult'. examResult-items looks like this:

          <itemtype code="Result" autocreate="true" generate="true">
         <deployment table="Results" typecode="10005" />
         <attributes>
             <attribute type="java.lang.Integer" qualifier="marks">
                 <persistence type="property"></persistence>
             </attribute>
             <attribute type="Trainee" qualifier="traineeId">
                 <persistence type="property"></persistence>
                 <modifiers unique="true" />
             </attribute>
         </attributes>
     </itemtype>



and then i am redeclaring the same itemtype in letsTravel like below:

     <itemtype code="Result" autocreate="false" generate="false">
         <attributes>
             <attribute type="TraineeExtended" qualifier="traineeId"
                 redeclare="true">
                 <persistence type="property"></persistence>
                 <modifiers unique="true" />
             </attribute>
         </attributes>
     </itemtype> 

i have included the extension in the required-extension tag. even after that it is showing the following error during build.

java.lang.IllegalArgumentException: cannot merge namespace ((letsTravel)) into (()) due to duplicate attribute 'Result.traineeId(TraineeExtended):((letsTravel))::YAttributeDescriptor[letsTravel-items.xml:106(AttributeTagListener)][null]' vs 'Result.traineeId(Trainee):((examResult))::YAttributeDescriptor[examResult-items.xml:92(AttributeTagListener)][PROPERTY]'

Accepted Solutions (1)

Accepted Solutions (1)

former_member620692
Active Contributor
0 Kudos

Hi - you are getting this error because you have redeclared traineeId in the same itemtype, Result. Please note that redeclaring an attribute is possible only in the subtype e.g. in the example given below, entries has been redeclared in Cart which is a subtype of AbstractOrder:

 <itemtype code="AbstractOrder" extends="GenericItem" jaloclass="de.hybris.platform.jalo.order.AbstractOrder" autocreate="true" generate="true" abstract="true">
   <custom-properties>
       <property name="legacyPersistence">
           <value>java.lang.Boolean.TRUE</value>
       </property>
   </custom-properties>
   <attributes>
     (....)
     <attribute autocreate="true" qualifier="entries" type="AbstractOrderEntryList">
        <persistence type="jalo"/>
        <modifiers read="true" write="true" search="true" partof="true" optional="true"/>
     </attribute>
 (....)

and then

 <itemtype code="Cart" extends="AbstractOrder" jaloclass="de.hybris.platform.jalo.order.Cart" autocreate="true" generate="true">
    <deployment table="Carts" typecode="43"/>
    <attributes>
       <attribute autocreate="true" redeclare="true" qualifier="entries" type="CartEntryCollection">
          <modifiers read="true" write="true" search="true" removable="true" optional="true" partof="false"/>
       </attribute>
       <attribute type="java.lang.String" qualifier="sessionId">
         <persistence type="property"/>
         <modifiers read="true" write="true"/>
       </attribute>
    </attributes>
 </itemtype>

More details at https://help.sap.com/viewer/d0224eca81e249cb821f2cdf45a82ace/1811/en-US/8bffa9cc86691014bb70ac2d0127...

0 Kudos

thanks a lot , your explanation is amazing....

former_member620692
Active Contributor
0 Kudos

You are most welcome.

0 Kudos

and if we have to change the type of an attribute of the employee itemtype in some extension. how will we do that?

former_member620692
Active Contributor
0 Kudos

Hybris doesn't allow to do it directly in the type. You can change the type of the attribute in a subtype, only to make it more specific i.e. only subtypes can be used as the new type of the attribute (as shown in the example given above).

Answers (0)