【问题标题】:Hazelcast Predicate in clauseHazelcast 谓词在子句中
【发布时间】:2020-07-09 01:04:55
【问题描述】:

谁能告诉我如何在 Hazelcast 谓词中加入子句。我想使用以下内容,

Predicates.in('column',value);

我想将值作为值的 ArrayList 传递。但它会抛出错误,因为它期望实现可比较的对象。有什么解决方法吗?

【问题讨论】:

    标签: hazelcast hazelcast-imap


    【解决方案1】:

    Predicates.in 接受类型参数(String、Comparable...)。

    因此,对于列名,您可以像之前那样传递一个字符串。 Comparable... 意味着您可以在逗号分隔的列表中传递各个值,但您也可以在数组中传递它们。 ArrayList 不会自动转换,但您可以这样做:

    ArrayList<String> values = new ArrayList<>(Arrays.asList("one", "two", "three");
    Predicates.in("column", values.toArray(new String[]));
    

    (new String[]) 参数只是为了确保您返回一个字符串数组,否则您将获得一个对象数组。

    【讨论】:

      猜你喜欢
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 2022-11-16
      • 2019-09-17
      • 1970-01-01
      • 2021-11-22
      • 1970-01-01
      相关资源
      最近更新 更多