spring-boot - HazelcastException:不能将 EqualPredicate 谓词与数组或集合属性一起使用
问题描述
我将用户及其位置存储在 hazelcast 中。当我对面临异常的位置进行查询时。
我正在使用 hazelcast 3.12.1版本
我遵循了 hazelcast 的参考手册 https://docs.hazelcast.org/docs/latest/manual/html-single/#querying-in-collections-and-arrays
Predicate pagingPredicate = new PagingPredicate<String, User>(
new SqlPredicate("userActive AND ( locations=null OR ( locations[any].country='India' AND locations[any].state='Telangana' AND locations[any].city='Hyderabad' ) )"), PRICE_COMPARATOR, 2);
return usersMap.values(pagingPredicate)
和我的 PriceComparator.java
public class PriceComparator implements Comparator<Entry<String, User>>,
Serializable {
private static final long serialVersionUID = -198157764684077461L;
@Override
public int compare(Entry<String, User> o1, Entry<String, User> o2) {
return Double.compare(o2.getValue().getSalary().doubleValue(),
o1.getValue().getSalary().doubleValue());
}
}
我希望缓存应该返回一些值,但我却面临异常
java.lang.IllegalArgumentException: Cannot use EqualPredicate predicate with an array or a collection attribute
谁可以帮我这个事。
解决方案
终于问题解决了。由于条件,这是一个问题locations=null
。当我用它替换这个条件时,locations.size=0
它工作得很好。
我无法弄清楚为什么null
检查集合会引发异常?
如果有人有答案请告诉我
推荐阅读
- python - 捕获特定的“Windows 错误”编号 - python
- owl - (关闭)Axiom 需要解决 Protégé Ontology 问题?
- python - tkinter 单选按钮和 mainloop 在 python3 中无法正常工作,使用 Enthought 的 Canopy
- ios - 我需要对我不拥有源代码的 iOS 应用程序进行自动化测试
- wpf - ListViewItem 滚动到视图中时的通知
- string - awk - 如何拆分找到的字符串
- drupal - 未捕获的 ReferenceError:未定义 googletag
- c++ - 我需要什么才能返回具有 unique_ptr 成员的对象?
- r - 嵌套模块中的闪亮按钮未显示;命名空间问题?
- html - 单击按钮后显示隐藏的对象不起作用