You are viewing a plain text version of this content. The canonical link for it is here.
Posted to user@ignite.apache.org by debashissinha <de...@gmail.com> on 2018/07/18 14:42:38 UTC

SqlQueryFileds on List of Binary Object

Hi ,

If I add a List<BinaryObject> to cache and also in the cache configuration I
set QueryEntity with fields, then how can I query using
cache.query(new SqlFieldQuery("Some sql"));

Sample I am trying to use is 

CacheConfiguration<Integer,List&lt;BinaryObject>> cfg = new
CacheConfiguration();
cfg.setQueryEntities(new ArrayList<QueryEntity>(){{

e.setKeyType("java.lang.Integer");
e.setValueType("Person");
e.setFields(new LinkedHashMap<String,String>(){{
  
    put("id","java.lang.Integer");
    put("name","java.lang.String");

}});
add(e);
}});

cfg.setName("TESTPERSON");

Ignite ignite = Ignition.start();
IgniteCache<Integer,List&lt;BinaryObject>> cache =
ignite.getOrCreateCache(cfg).withKeepBinary();

List<BinaryObject> binaryObjectList = new ArrayList<BinaryObject>();
IgniteBinary binary = binary.builder("Person");

bldr.setField("id",1);
bldr.setField("name","test");
binaryObjectList.add(bldr.build());

cache.put(1,binaryObjectList);

QueryCursor<List&lt;?>> cursor = cache.query(new SqlFieldsQuery("Select *
from Person"));

Am getting empty results here.
Can some one kindly help .

Thanks in advance.
Debashis Sinha



--
Sent from: http://apache-ignite-users.70518.x6.nabble.com/

Re: SqlQueryFileds on List of Binary Object

Posted by ezhuravlev <e....@gmail.com>.
Hi,

As for now, it's not possible to query objects if they're stored as
collection like IgniteCache
<Integer, List&lt;BinaryObject>>, so, I'd recommend changing the way how you
store objects in cache - it will be pretty the same if you will store it
like IgniteCache<Integer, BinaryObject>

Evgenii



--
Sent from: http://apache-ignite-users.70518.x6.nabble.com/

Re: SqlQueryFileds on List of Binary Object

Posted by debashissinha <de...@gmail.com>.
Hi ,
The Reason is i am trying to do it though load method , which supports the
read through. The requirement is to pass a set of param say
Map<String,String> which will contain a sql statement some query param value
and the return will be the list of BinaryObject . That is against one key I
want to hold all the binaryobejct and then query it from within the list
using SqlQueryFields



--
Sent from: http://apache-ignite-users.70518.x6.nabble.com/

Re: SqlQueryFileds on List of Binary Object

Posted by Ilya Kasnacheev <il...@gmail.com>.
Hello!

Why do you try to store List<BinaryObject> in cache? It should work if you
will just put plain BinaryObject's in it without List<>.

Regards,

-- 
Ilya Kasnacheev

2018-07-18 17:42 GMT+03:00 debashissinha <de...@gmail.com>:

> Hi ,
>
> If I add a List<BinaryObject> to cache and also in the cache configuration
> I
> set QueryEntity with fields, then how can I query using
> cache.query(new SqlFieldQuery("Some sql"));
>
> Sample I am trying to use is
>
> CacheConfiguration<Integer,List&lt;BinaryObject>> cfg = new
> CacheConfiguration();
> cfg.setQueryEntities(new ArrayList<QueryEntity>(){{
>
> e.setKeyType("java.lang.Integer");
> e.setValueType("Person");
> e.setFields(new LinkedHashMap<String,String>(){{
>
>     put("id","java.lang.Integer");
>     put("name","java.lang.String");
>
> }});
> add(e);
> }});
>
> cfg.setName("TESTPERSON");
>
> Ignite ignite = Ignition.start();
> IgniteCache<Integer,List&lt;BinaryObject>> cache =
> ignite.getOrCreateCache(cfg).withKeepBinary();
>
> List<BinaryObject> binaryObjectList = new ArrayList<BinaryObject>();
> IgniteBinary binary = binary.builder("Person");
>
> bldr.setField("id",1);
> bldr.setField("name","test");
> binaryObjectList.add(bldr.build());
>
> cache.put(1,binaryObjectList);
>
> QueryCursor<List&lt;?>> cursor = cache.query(new SqlFieldsQuery("Select *
> from Person"));
>
> Am getting empty results here.
> Can some one kindly help .
>
> Thanks in advance.
> Debashis Sinha
>
>
>
> --
> Sent from: http://apache-ignite-users.70518.x6.nabble.com/
>