0

谁能帮我解决这个棘手的问题,我已将 jpacontainer 设置为 vaadin 组合框的数据源,并为其设置了过滤模式,但过滤不起作用,它在这里抛出异常。

代码:

JPAContainer<PersonMaster> personMasterContainer = new JPAContainer<>(PersonMaster.class);
personMasterContainer.setEntityProvider(dataService.getPersonMasterService());

ComboBox createEntitySelect = new ComboBox("Entity",personMasterContainer);
createEntitySelect.setContainerDataSource(personMasterContainer);
createEntitySelect.setItemCaptionPropertyId("personName");
createEntitySelect.setFilteringMode(ComboBox.FILTERINGMODE_CONTAINS);
createEntitySelect.setImmediate(true);

异常堆栈跟踪:

SEVERE: EjbTransactionUtil.handleSystemException: The filter listener "matches" requires a constant argument.
<openjpa-2.4.0-r422266:1674604 nonfatal user error> org.apache.openjpa.persistence.ArgumentException: The filter listener "matches"requires a constant argument.     
at org.apache.openjpa.jdbc.kernel.exps.JDBCExpressionFactory.matches(JDBCExpressionFactory.java:276)
at org.apache.openjpa.persistence.criteria.Expressions$Like.toKernelExpression(Expressions.java:1265)
at org.apache.openjpa.persistence.criteria.PredicateImpl.toKernelExpression(PredicateImpl.java:166)
at org.apache.openjpa.persistence.criteria.CriteriaExpressionBuilder.evalFilter(CriteriaExpressionBuilder.java:215)
at org.apache.openjpa.persistence.criteria.CriteriaExpressionBuilder.getQueryExpressions(CriteriaExpressionBuilder.java:75)
at org.apache.openjpa.persistence.criteria.CriteriaQueryImpl.getQueryExpressions(CriteriaQueryImpl.java:423)
at org.apache.openjpa.persistence.criteria.CriteriaBuilderImpl.eval(CriteriaBuilderImpl.java:81)
at org.apache.openjpa.kernel.ExpressionStoreQuery$DataStoreExecutor.<init>(ExpressionStoreQuery.java:763)
at org.apache.openjpa.kernel.ExpressionStoreQuery.newDataStoreExecutor(ExpressionStoreQuery.java:179)
at org.apache.openjpa.kernel.QueryImpl.createExecutor(QueryImpl.java:748)
at org.apache.openjpa.kernel.QueryImpl.compileForDataStore(QueryImpl.java:706)
at org.apache.openjpa.kernel.QueryImpl.compileForExecutor(QueryImpl.java:688)
at org.apache.openjpa.kernel.QueryImpl.getOperation(QueryImpl.java:1528)
at org.apache.openjpa.kernel.DelegatingQuery.getOperation(DelegatingQuery.java:123)
at org.apache.openjpa.persistence.QueryImpl.execute(QueryImpl.java:268)
at org.apache.openjpa.persistence.QueryImpl.getResultList(QueryImpl.java:290)
at org.apache.openjpa.persistence.QueryImpl.getSingleResult(QueryImpl.java:318)
at com.vaadin.addon.jpacontainer.provider.LocalEntityProvider.doGetEntityCount(LocalEntityProvider.java:543)
at com.vaadin.addon.jpacontainer.provider.LocalEntityProvider.getEntityCount(LocalEntityProvider.java:547)
at sun.reflect.GeneratedMethodAccessor66.invoke(Unknown Source)
at sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:43)
at java.lang.reflect.Method.invoke(Method.java:497)
4

1 回答 1

0

错误

过滤器侦听器“匹配”需要一个常量参数

当您尝试使用诸如 cb.lower(value) 作为第二个参数的表达式进行类似操作时,在 openjpa 中给出。您可以完全省略较低的运算符,因为

MySQL DB - 'like' 运算符以不区分大小写的方式使用

所以你可以写下类似下面的代码:

Predicate condition = cb.like(cb.lower(field), "%" + value+ "%");

它应该按预期工作。

帮助我找到根本原因的来源

于 2018-04-30T13:08:03.200 回答