ignite-user mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From vkulichenko <valentin.kuliche...@gmail.com>
Subject Re: How can query data from multiple caches,like sql UNION
Date Fri, 21 Aug 2015 21:41:44 GMT
cuike wrote
> I have a two cache,threy are store same object .But I want to qurey all
> data from the two cache,like sql union ,union all data from the  two
> cache.
> code in
> https://github.com/sdcuike/Ignite-2015/blob/master/src/main/java/com/doctor/ignite/example/spring/CrossCacheQueries.java
> The result is: only have one cache values,not all cache values;
> I see
> :http://apache-ignite-users.70518.x6.nabble.com/UNION-still-not-working-with-1-0-2-td178.html#a182


You query doesn't have UNION clause at all, that's why it returns values
from one cache only. To make it work you should use SqlFieldsQuery and
select special _val field from both caches. This is an internal field that
is automatically added to any table and contains the reference to the
corresponding cache entry value. Here is how you should declare the query:

SqlFieldsQuery sqlQuery = new SqlFieldsQuery("select _val from Person union
select _val from \"person2\".Person");

Actually, is there any reason for having two caches with one data type? I'm
not sure I understand your use case. Can you clarify?


View this message in context: http://apache-ignite-users.70518.x6.nabble.com/How-can-query-data-from-multiple-caches-like-sql-UNION-tp1082p1095.html
Sent from the Apache Ignite Users mailing list archive at Nabble.com.

View raw message