You are viewing a plain text version of this content. The canonical link for it is here.
Posted to issues@ignite.apache.org by "Yury Gerzhedovich (Jira)" <ji...@apache.org> on 2021/12/13 08:41:00 UTC
[jira] [Resolved] (IGNITE-15871) when use affinity_key and two fields as primary key, key-value api can't get the data of sql insert ,and binary write data can't get primary key fields value with sql
[ https://issues.apache.org/jira/browse/IGNITE-15871?page=com.atlassian.jira.plugin.system.issuetabpanels:all-tabpanel ]
Yury Gerzhedovich resolved IGNITE-15871.
----------------------------------------
Resolution: Invalid
> when use affinity_key and two fields as primary key, key-value api can't get the data of sql insert ,and binary write data can't get primary key fields value with sql
> ----------------------------------------------------------------------------------------------------------------------------------------------------------------------
>
> Key: IGNITE-15871
> URL: https://issues.apache.org/jira/browse/IGNITE-15871
> Project: Ignite
> Issue Type: Bug
> Components: binary, cache, sql
> Affects Versions: 2.10
> Reporter: w w
> Priority: Major
> Attachments: image-2021-11-04-17-59-07-391.png, image-2021-11-04-18-05-13-766.png, image-2021-11-04-18-06-16-270.png
>
>
> # I use sql create table like this;
> {code:java}
> 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";
> {code}
>
> # insert data with sql;
> {code:java}
> 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');
> {code}
> # now Binary_metadata view like this : !image-2021-11-04-17-59-07-391.png|width=1888,height=1015!
> # then I use key-value api add data and query data:
> # code like this:
> {code:java}
> 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");
> }
> {code}
> but can't find the row of ( id=1 and companyId=1 )
> and binaryCache.put(akey, bldr.build()); with sql query like this: !image-2021-11-04-18-05-13-766.png!
> now view of binary_metadata: !image-2021-11-04-18-06-16-270.png!
--
This message was sent by Atlassian Jira
(v8.20.1#820001)