Hybris 控制台:
ERROR [hybrisHTTP19] [FlexibleSearch] Flexiblesearch error: missing values for [emailId, productCode], got {13=8796135981138, issent=false, productcode =0100, emailid ='[email protected]'}
ERROR [hybrisHTTP19] [FlexibleSearch] query was 'SELECT {p:pk} FROM {NotifyStock AS p} WHERE {p:status}=?isSent AND {p:productId}=?productCode AND {p:emailId}=?emailId '
ERROR [hybrisHTTP19] [FlexibleSearch] translated query was: SELECT item_t0.PK FROM notifystock item_t0 WHERE ( item_t0.p_status =? AND item_t0.p_productid =? AND item_t0.p_emailid =?) AND (item_t0.TypePkString=? )
Aug 31, 2015 6:51:35 PM org.apache.catalina.core.StandardWrapperValve invoke
SEVERE: Servlet.service() for servlet [DispatcherServlet] in context with path [/store] threw exception [Request processing failed; nested exception is de.hybris.platform.servicelayer.search.exceptions.FlexibleSearchException: missing values for [emailId, productCode], got {13=8796135981138, issent=false, productcode =0100, emailid ='[email protected]'}] with root cause
de.hybris.platform.jalo.flexiblesearch.FlexibleSearchException: missing values for [emailId, productCode], got {13=8796135981138, issent=false, productcode =0100, emailid ='[email protected]'}[HY-0]
at de.hybris.platform.persistence.flexiblesearch.TranslatedQuery.removeUnusedValues(TranslatedQuery.java:274)
at de.hybris.platform.jalo.flexiblesearch.FlexibleSearch.search(FlexibleSearch.java:1423)
at de.hybris.platform.jalo.flexiblesearch.FlexibleSearch.search(FlexibleSearch.java:1627)
at de.hybris.platform.servicelayer.search.impl.DefaultFlexibleSearchService$2.execute(DefaultFlexibleSearchService.java:374)
at de.hybris.platform.servicelayer.search.impl.DefaultFlexibleSearchService$2.execute(DefaultFlexibleSearchService.java:1)
at de.hybris.platform.servicelayer.session.impl.DefaultSessionService.executeInLocalView(DefaultSessionService.java:88)
at de.hybris.platform.servicelayer.search.impl.DefaultFlexibleSearchService.getJaloResult(DefaultFlexibleSearchService.java:363)
at de.hybris.platform.servicelayer.search.impl.DefaultFlexibleSearchService.search(DefaultFlexibleSearchService.java:164)
at de.hybris.merchandise.core.notifystock.NotifyStockServices.isAlreadyExists(NotifyStockServices.java:118)
at de.hybris.merchandise.facades.NotifyStock.impl.NotifyStockFacadeImpl.isAlreadyExists(NotifyStockFacadeImpl.java:51)
at de.hybris.merchandise.storefront.controllers.misc.AddToCartController.verifyEmail(AddToCartController.java:132)
HAC 中的工作查询:
select {p:PK} From {NotifyStock AS p} WHERE {p:status}=0 AND {p:productId}=0100 AND {p:emailId}='[email protected]'
灵活搜索查询(不工作):
final StringBuilder builder = new StringBuilder();
builder.append("SELECT {p:").append(ItemModel.PK).append("} ");
builder.append("FROM {").append(NotifyStockModel._TYPECODE).append(" AS p} ");
builder.append("WHERE ").append("{p:").append(NotifyStockModel.STATUS).append("}").append("=?isSent ");
builder.append("AND ").append("{p:").append(NotifyStockModel.PRODUCTID).append("}").append("=?productCode ");
builder.append("AND ").append("{p:").append(NotifyStockModel.EMAILID).append("}").append("=?emailId ");
final String email = "\'" + notifyStockModel.getEmailId() + "\'";
final FlexibleSearchQuery query = new FlexibleSearchQuery(builder.toString());
query.setNeedTotal(true);
query.addQueryParameter("isSent", Boolean.FALSE);
query.addQueryParameter("productCode ", notifyStockModel.getProductId());
query.addQueryParameter("emailId ", email);
当我在 HAC 中触发上述查询时,查询工作正常,但是当我使用灵活搜索触发相同查询时,我遇到了一些灵活搜索异常。谁能告诉我灵活搜索查询中的错误是什么?任何帮助将不胜感激?
最佳答案
除了 Shresht 的回答之外,还要养成在参数映射中使用字段名称常量的习惯。
例子 :
query.addQueryParameter(NotifyStockModel.PRODUCTID, notifyStockModel.getProductId());
query.addQueryParameter(NotifyStockModel.EMAILID, email);
上述语法永远不会导致问题。同样对于此类直接匹配查询,我建议您使用灵活搜索的以下方法:
flexibleSearchService.getModelByExample(示例)
这导致更易于维护的代码。查看维基以获取更多信息。
关于mysql - 灵活搜索错误 : missing values,我们在Stack Overflow上找到一个类似的问题:https://stackoverflow.com/questions/32313139/