Warning: file_get_contents(/data/phpspider/zhask/data//catemap/9/java/308.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181

Warning: file_get_contents(/data/phpspider/zhask/data//catemap/9/google-apps-script/6.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181
Java Hazelcast查询可以与对象方法一起工作吗?_Java_Spring_Hazelcast_Spring El - Fatal编程技术网

Java Hazelcast查询可以与对象方法一起工作吗?

Java Hazelcast查询可以与对象方法一起工作吗?,java,spring,hazelcast,spring-el,Java,Spring,Hazelcast,Spring El,我在文档中找不到这个 如果hazelcast缓存中有复杂对象: public class MyObj { private int something; private AnotherObject complexMember; } 我可以做: map.values(new SqlPredicate("something > 3 AND complexMember.someProperty > 3")); 我知道@Cachable注释在可能的情况下使用。有没有可能以某

我在文档中找不到这个

如果hazelcast缓存中有复杂对象:

public class MyObj {
    private int something;
    private AnotherObject complexMember;
}
我可以做:

map.values(new SqlPredicate("something > 3 AND complexMember.someProperty > 3"));
我知道
@Cachable
注释在可能的情况下使用。有没有可能以某种方式通过编程来实现呢


谢谢,

可以。试着跟随

public static void main(String[] args) throws Exception {
    final HazelcastInstance hz = Hazelcast.newHazelcastInstance(null);
    final IMap map = hz.getMap("test");
    map.put(1, new MyObj(1, new AnotherObject("value")));

    System.out.println(map.values(new SqlPredicate("something > 0 and complexMember.someString like 'val%'")));
}

static class MyObj implements Serializable {
    private int something;
    private AnotherObject complexMember;

    MyObj(final int something, final AnotherObject complexMember) {
        this.something = something;
        this.complexMember = complexMember;
    }
}

static class AnotherObject implements Serializable  {
    private String someString;

    AnotherObject(final String someString) {
        this.someString = someString;
    }
}