sap-commerce-cloud

java.lang.IllegalArgumentException: invalid pks [10] - unknown typecode 0


I'm trying to fire Flexible Search Query from DAO layer. My query is something like:

SELECT {loyaltypoints},{redeemedloyaltypoints}  
FROM {LoyaltyUser} 
WHERE {uid} =?uid

is throwing me unknown type code but my type code is proper. I see the stack trace message like

SEVERE: Servlet.service() for servlet [DispatcherServlet] in context with path [/store]
threw exception [Request processing failed; nested exception is java.lang.IllegalArgumentException:
    invalid pks [10] - unknown typecode 0] with root cause
    java.lang.IllegalArgumentException: invalid pks [10] - unknown typecode 0
    at de.hybris.platform.core.WrapperFactory.getCachedItems(WrapperFactory.java:304)
    at de.hybris.platform.core.LazyLoadItemList.loadPage(LazyLoadItemList.java:230)
    at de.hybris.platform.servicelayer.search.impl.LazyLoadModelList.loadPage(LazyLoadModelList.java)"

My items.xml looks like:

<itemtype code="LoyaltyUser" extends="Customer" autocreate="true" generate="true"
    jaloclass="de.hybris.merchandise.core.jalo.LoyaltyUser">
    <deployment table="LoyaltyUsers" typecode="10010"/>
    <attributes>
        <attribute generate="true" autocreate="true" qualifier="loyaltypoints" type="java.lang.Integer" >
            &ltdescription&gtLoyalty points given for each purchase&lt/description&gt
            <modifiers read="true" write="true" search="true" optional="true" />
            <defaultvalue>Integer.valueOf(0)</defaultvalue>
            <persistence type="property"/>
        </attribute>
        <attribute generate="true" autocreate="true" qualifier="redeemedloyaltypoints" type="java.lang.Integer" >
            <description>Redeemed Loyalty points For a customer</description>
            <modifiers read="true" write="true" search="true" optional="true" />
            <defaultvalue>Integer.valueOf(0)</defaultvalue>
            <persistence type="property"/>
        </attribute>
    </attributes>
</itemtype>

Could anyone help me out from this issue?


Solution

  • Rather than getting two attribute {loyaltypoints},{redeemedloyaltypoints} in query, you should get PK of your LoyaltyUser Model.

    SELECT {pk} FROM {LoyaltyUser} WHERE {uid} =?uid

    Query will give LoyaltyUserModel then you can get its attribute by getter method.

    Integer loyalyPoint = loyaltyUserModel.getLoyaltypoints()
    Integer redeemedLoyaltyPoint = loyaltyUserModel.getRedeemedloyaltypoints()