Details
Description
- I use sql create table like this;
CREATE TABLE IF NOT EXISTS Person ( id int, name varchar, test int, test2 varchar, companyId Long, PRIMARY KEY (id, companyId) ) WITH "template=partitioned,backups=1,affinity_key=companyId,KEY_TYPE=AffinityKey,VALUE_TYPE=Person";
- insert data with sql;
insert into Public.Person(id,companyId,test,test2,name) values(1,1,1,'test11','test1'); insert into Public.Person(id,companyId,test,test2,name) values(2,1,1,'test1','test'); insert into Public.Person(id,companyId,test,test2,name) values(3,1,1,'test3','test3');
- now Binary_metadata view like this :
- then I use key-value api add data and query data:
- code like this:
Ignite ignite = Ignition.ignite(); IgniteCache<AffinityKey, Person> personCache = ignite.getOrCreateCache("SQL_PUBLIC_PERSON"); IgniteCache<AffinityKey, BinaryObject> binaryCache = ignite.cache("SQL_PUBLIC_PERSON").withKeepBinary(); IgniteCache<AffinityKey, Object> objCache = ignite.cache("SQL_PUBLIC_PERSON"); var akey= new AffinityKey<Integer>(7,1L); IgniteBinary binary = ignite.binary(); BinaryObjectBuilder bldr = binary.builder("Person"); bldr.setField("ID",7,Integer.class); bldr.setField("COMPANYID",1L ); bldr.setField("TEST",1 ); bldr.setField("TEST2","test21"); bldr.setField("NAME","test7"); // Person p3=new Person(5,1L,"test3"); binaryCache.put(akey, bldr.build()); if(personCache.containsKey(akey)) { BinaryObject bo=binaryCache.get(akey); System.out.println("id:"+bo.field("id")); System.out.println("companyId:"+bo.field("COMPANYID")); } akey= new AffinityKey(1, 1L); if(personCache.containsKey(akey)) { System.out.println("ok2"); } if(binaryCache.containsKey(akey)) { System.out.println(" binaryCache ok"); } if(objCache.containsKey(akey)) { System.out.println("objCache ok"); }
but can't find the row of ( id=1 and companyId=1 )
and binaryCache.put(akey, bldr.build()); with sql query like this:
now view of binary_metadata: