我在文档中找不到这个。
如果我在hazelcast缓存中有一个复杂的对象:
public class MyObj {
private int something;
private AnotherObject complexMember;
}
我可以这样做:
map.values(new SqlPredicate("something > 3 AND complexMember.someProperty > 3"));
我知道@Cachable
注释使用SpEL这是可能的。有可能以某种方式以编程方式进行吗?
谢谢,
答案 0 :(得分:5)
是的可能。请尝试以下内容;
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;
}
}