No, it needs to be able to determine which node the data should be on without reference to anything else. This means that you’d need company-id in your address table.
> On 13 May 2020, at 21:23, narges saleh <snarges...@gmail.com> wrote: > > > My other question is whether affinity is transitive. > Company (primary key: company-id) > Employee(primary key: employee-id + company-id) <- company id = affinity key > Address(Primary key: address-id + employee -id) <- employee id = affinity key > > Would the records related company, employee and address for the employee end > up on the same node? In other words, I won't need to drag company id in the > address table, in order to collocate all three record types. > >> On Wed, May 13, 2020 at 10:50 AM narges saleh <snarges...@gmail.com> wrote: >> Thanks. >> If I try AffinityRun with collection of caches and the affinity key, I'd get >> NPE with cache.localpeek using the primary key of the dependent cache/table >> but the cache query itself succeeds. >> Is there a working example? >> >>> On Wed, May 13, 2020 at 8:10 AM Stephen Darlington >>> <stephen.darling...@gridgain.com> wrote: >>> Yes, but you also need to make sure you use the correct affinityRun method. >>> There’s one where you specify multiple caches and you need to use that one. >>> >>> > On 13 May 2020, at 12:50, narges saleh <snarges...@gmail.com> wrote: >>> > >>> > Hi All, >>> > If I have these two caches/tables defined via query entities, in a >>> > config file, >>> > Employee (partitioned) >>> > employee-id >>> > company-id >>> > name >>> > primary key(employee-id, company-id), affinity(company-id) >>> > >>> > Company (partitioned) >>> > company-id. >>> > name >>> > primary key(company-id) >>> > >>> > If I do AffinityRun or mapkeystonodes with two server ignite nodes >>> > running on the same physical box, shouldn't I see the employee records >>> > with the same company-id and the company record with the same company-id >>> > on the same ignite node? >>> > >>> > thanks. >>> > >>> >>>