I am still not getting it. The field affinityId in my data key is just like any other field which hold the value of affinity key column. For cache1 it will hold subscriptionId and for other cache it might hold value of some other affinity key.
But when I write SQL like 'select * from Cahce_1 where subscriptionId = ?' , how does ignite understands that column name subscriptionId is a affifiny key of cache_1. I have not mentioned anywhere that column name subscriptionId is a affinity key. I put an entries in my caches by creating key as follows. new DefaultDataAffinityKey(id1, subscriptionId); new DefaultDataAffinityKey(id2, someotherId); Here I am just passing the values to this key. Nowhere I am mentioning the column name of primary key or affinity key. How ignite idetifies that out of 5 columns provided in where clause of SQL , this particular column is a affinity key or primary key. On Wed, Aug 22, 2018, 7:52 AM vkulichenko <valentin.kuliche...@gmail.com> wrote: > There are several ways to do this. > > First one is shown in your first message - DefaultDataAffinityKey instance > plays the role of primary key, while enclosed affinityId field plays the of > affinity key, because it's annotated with @AffinityKeyMapped. > > In case you don't have classes at all and therefore can't use annotations > (for example, if you create all your objects using BinaryObjectBuilder), > you > can specify field name to be used as affinity key via > CacheKeyConfiguration. > > Finally, if you use DDL to create your tables, affinity key field name can > be specified as a part of CREATE TABLE command: > https://apacheignite-sql.readme.io/docs/create-table > > Either way, affinity key is ALWAYS a part of the primary key, so there is > no > way to select by primary key without specifying the value for affinity key. > But it's enough to provide ONLY affinity key to achieve the routing. > > -Val > > > > -- > Sent from: http://apache-ignite-users.70518.x6.nabble.com/ >