javasap-commerce-cloudbackoffice

SAP Hybris can't create custom banner component


I want to create custom banner component, extended from SimpleBannerComponent. But after I created it, it fails to create in Backoffice, see below.

1) I added this item to my *-items.xml file.

<itemtype code="PromotionBannerCMSComponent" autocreate="true" generate="true" extends="SimpleBannerComponent"
          jaloclass="my.package.core.jalo.components.PromotionBannerCMSComponent">
    <description>Promotion banner component</description>
    <deployment table="PromotionBanners" typecode="15301"/>
    <attributes>
        <attribute qualifier="code" type="java.lang.String">
            <persistence type="property"/>
            <modifiers/>
            <description>Banner name (not unique)</description>
        </attribute>
        <attribute qualifier="title" type="localized:java.lang.String">
            <description>Title</description>
            <modifiers read="true" write="true" search="true" initial="true"/>
            <persistence type="property"/>
        </attribute>
        <attribute qualifier="position" type="SimpleBannerPositionEnum">
            <description>Banner position</description>
            <modifiers optional="true" initial="true"/>
            <persistence type="property"/>
        </attribute>
        <attribute qualifier="altText" type="localized:java.lang.String">
            <description>Banner alt text</description>
            <modifiers optional="true" initial="true"/>
            <persistence type="property"/>
        </attribute>
        <attribute qualifier="titleSecondary" type="localized:java.lang.String">
            <description>Title secondary</description>
            <persistence type="property" />
            <modifiers />
        </attribute>
        <attribute qualifier="urlLoc" type="localized:java.lang.String">
            <description>Banner url</description>
            <persistence type="property" />
            <modifiers />
        </attribute>
    </attributes>
</itemtype>

2) I did ant clean all, restarted server, I've run HAC -> Update with my custom extension checked and with Update running system also checked. Then I did a server restart again.

3) I wanted to create the component in the Backoffice WCMS->Components->Add, but it fails with error - I've turned on the flexible.search.exception.show.query.details to see it:

 [ConfigurableFlowController] Object  could not be saved
com.hybris.cockpitng.dataaccess.facades.object.exceptions.ObjectSavingException: Object  could not be saved

and

Caused by: de.hybris.platform.servicelayer.exceptions.ModelSavingException: [de.hybris.platform.servicelayer.interceptor.impl.UniqueAttributesInterceptor@716c1b71]: unexpected validator error: SQL search error - Unknown column 'item_t0.p_catalogversion' in 'where clause' query = 'SELECT  item_t0.PK  FROM cmscomponent item_t0 WHERE
.
.

Now I can't create even the basic SimpleBannerComponent, neither the other components. Is there something wrong with the update? I'm using Hybris 1811.18.


Solution

  • Turns out I had an old deployment table which collided with this component, somehow it didn't show an error during ant clean all.

    So I run in HAC delete from ydeployments where typecode=XX; (XX is typecode found in HAC) and started over with almost the same deployment, except I removed jaloclass and deployment table description:

    <itemtype code="PromotionBannerCMSComponent" autocreate="true" generate="true" extends="SimpleBannerComponent">
        <description>Promotion banner component</description>
        <attributes>
            <attribute qualifier="code" type="java.lang.String">
                <persistence type="property"/>
                <modifiers/>
                <description>Banner name (not unique)</description>
            </attribute>
            <attribute qualifier="title" type="localized:java.lang.String">
                <description>Title</description>
                <modifiers read="true" write="true" search="true" initial="true"/>
                <persistence type="property"/>
            </attribute>
            <attribute qualifier="position" type="SimpleBannerPositionEnum">
                <description>Banner position</description>
                <modifiers optional="true" initial="true"/>
                <persistence type="property"/>
            </attribute>
            <attribute qualifier="altText" type="localized:java.lang.String">
                <description>Banner alt text</description>
                <modifiers optional="true" initial="true"/>
                <persistence type="property"/>
            </attribute>
            <attribute qualifier="titleSecondary" type="localized:java.lang.String">
                <description>Title secondary</description>
                <persistence type="property" />
                <modifiers />
            </attribute>
            <attribute qualifier="urlLoc" type="localized:java.lang.String">
                <description>Banner url</description>
                <persistence type="property" />
                <modifiers />
            </attribute>
        </attributes>
    </itemtype>