ignite-user mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From Denis Magda <dma...@gridgain.com>
Subject Re: Queries including sub-classes
Date Mon, 21 Dec 2015 10:02:53 GMT
Hi,

Presently in SQL queries you can't use a predecessor's name to retrieve 
data for all its subclasses stored in a cache.
The reason is that for every type, registered with CacheConfiguration, 
Ignite creates a corresponding flat H2 type descriptor that doesn't 
store hierarchy information.

The only way to support your use case is to list all the types you want 
to choose from explicitly in a query.

As an example if you want to get all text files and images named 'test' 
you can use the query below

SqlFieldsQuery query =new SqlFieldsQuery(
     "SELECT _val FROM Image WHERE name = 'test' " +
     "UNION " +
     "SELECT _val FROM Text WHERE name = 'test'");

List<List<?>> result = cache.query(query).getAll();

for (List val : result)
     for (Object file : val)
         System.out.println("File: " + file);



Community, what do you think if we introduce a kind of types aliasing 
that will support use cases like this?

Regards,
Denis

On 12/20/2015 10:32 PM, Aolean wrote:
> Hello,
>
> I'm trying to define the best design for the following situation:
>
> - I have an abstract class File representing a description of a file (with
> attributes like name, machine on which it is hosted, path, ...)
> - I have several sub-classes extending File (Image, Doc, CSV, Excel, ...)
> with more details.
>
> I want to push those descriptions in the cache, and being able to do queries
> on them:
> - Searching all files with a given name
> - Searching all images with a given name, ...
>
> Declaring a sql search like this:
> SqlQuery<Integer, File > sql = new SqlQuery(File.class, "name = 'Test'");
>
> will not give the desired result because only classes exactly matching
> "File" will be returned.
> Is there a way to indicate that we want to include sub-classes as well in
> the query ?
>
> I didn't find any example corresponding to this situation so far.
>
> Thanks
>
>
>
> --
> View this message in context: http://apache-ignite-users.70518.x6.nabble.com/Queries-including-sub-classes-tp2259.html
> Sent from the Apache Ignite Users mailing list archive at Nabble.com.


Mime
View raw message