java.lang.IllegalArgumentException:无效的pks [10] - 未知的类型代码0

时间:2016-07-15 08:58:07

标签: hybris

我正在尝试从DAO层启动灵活搜索查询。我的查询类似于:

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

告诉我未知的类型代码,但我的类型代码是正确的。我看到像

这样的堆栈跟踪消息
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)"

我的items.xml看起来像是:

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

有人可以帮我解决这个问题吗?

1 个答案:

答案 0 :(得分:4)

您不应在查询中获得两个属性{loyaltypoints}{redeemedloyaltypoints},而应获得LoyaltyUser模型的PK。

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

查询将提供LoyaltyUserModel,然后您可以通过getter方法获取其属性。

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