当前位置: 动力学知识库 > 问答 > 编程问答 >

java - Parameterized search in Oracle Coherence returns empty list

问题描述:

I've got a problem with search in Coherence using IN statement and parameterized list.

Here I'm creating cache with sample data:

NamedCache cache = CacheFactory.getCache("test-cache");

Some s2 = new Some();

s2.setId(2);

s2.setName("name 2");

cache.put("K2", s2);

Some s3 = new Some();

s3.setId(3);

s3.setName("name 3");

cache.put("K3", s3);

Here I'm trying to obtain results using parameterized query:

Map<String, ? super Object> map = new HashMap();

map.put("keys", Arrays.asList(new String [] {"K1","K2"}));

Filter filter = QueryHelper.createFilter("key() in :keys", map);

List<Some> list = new ArrayList<Some>(cache.entrySet(filter));

System.out.println(filter); prints what appears to be proper filter configuration:

InFilter(KeyExtractor(extractor=IdentityExtractor), [[K1, K2]])

I'm expecting it to return list with single element with key K2, but it returns empty list.

However, I get proper result if I print key list manually into query string:

Filter filter = QueryHelper.createFilter("key() in ('K1','K2')");

System.out.println(filter); in this case prints basically the same:

InFilter(KeyExtractor(extractor=IdentityExtractor), [K1, K2])

Oracle Coherence 3.7.1.0

Thanks in advance

网友答案:

The two filters are not quite the same. This seems to work:

 map.put("keys", new String [] {"K1","K2"});
分享给朋友:
您可能感兴趣的文章:
随机阅读: