Obtaining query results
The easiest way to obtain query results is to invoke one of the QueryMap.entrySet
methods:
Filter filter = ...; Set<Map.Entry> results = cache.entrySet(filter);
This will return a set of Map.Entry
instances representing both the key and the value of a cache entry, which is likely not what you want. More often than not you need only values, so you will need to iterate over the results and extract the value from each Map.Entry
instance:
List values = new ArrayList(results.size()); for (Map.Entry entry : entries) { values.add(entry.getValue()); }
After doing this a couple times you will probably want to create a utility method for this task. Because all the queries should be encapsulated within various repository implementations, ...
Get Oracle Coherence 3.5 now with the O’Reilly learning platform.
O’Reilly members experience books, live events, courses curated by job role, and more from O’Reilly and nearly 200 top publishers.