sap-commerce-cloud - java.lang.IllegalArgumentException : invalid pks [10] - unknown typecode 0 异常

标签 sap-commerce-cloud

我正在尝试从 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>

谁能帮我解决这个问题?

最佳答案

与其在查询中获取两个属性 {loyaltypoints},{redeemedloyaltypoints},不如获取 LoyaltyUser 模型的 PK。

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

查询会给出 LoyaltyUserModel 然后你可以通过 getter 方法获取它的属性。

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

关于sap-commerce-cloud - java.lang.IllegalArgumentException : invalid pks [10] - unknown typecode 0 异常,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/38392003/

相关文章:

java - 当使用另一个按钮 - HYBRIS 进行操作时,如何禁用后台中的按钮?

java - 如何调整 IntelliJ 来构建 Hybris 项目?

sap-commerce-cloud - hybris 中 Translator 与 Cell Decorator,什么情况下优先选择哪一个

sap-commerce-cloud - 在 hybris 5.7 中自定义 B2C 加速器时出错

java - 如何根据底价或总价查找适用促销的地方?

validation - 如何从 Hybris 1905 中删除 CustomerName 验证,以便在创建客户时可以不使用名称?

java - 访问地址时出现服务器错误,但没有堆栈跟踪

java - 为什么oldCartRemovalJob 被放置在<custom-name>commercewebservices 中?

sap-commerce-cloud - 海布里斯 : difference between promotion and voucher

java - 当我们执行 Modelservice.Save() 时,Hybris 会做什么?