Hi,
AffinityKeyMapped annotation allows to exclude some fields from affinity
key calculations but still use it in cache key. Field areaId was already
excluded from affinity calculation for OrganizationKey by applying
annotation. And for second entity Employee correct option is as follows:
public class EmployeeKey {
private int id;
/** ID. */
/** Organization ID. */
@AffinityKeyMapped
private int organizationId;
}
For both calculations of affinity key for OranizationKey and EmployeeKey we
will get same result for same organizationId and values will be collocated.
Sincerely,
Dmitriy Pavlov
вс, 29 окт. 2017 г. в 7:27, Bob Li <[email protected]>:
> Cache mode is partitioned.
> I have three objects: Area, Organization and Employee and codes as the
> following.
>
> *Code:*
> public class Area implements Serializable {
> private int id;
> private String name;
> ...
> }
>
> public class Organization implements Serializable {
> private iint id;
> private String name;
> ...
> }
>
> public class Employee implements Serializable {
> private int id;
> private String name;
> ...
> }
>
>
> The first level collocation class is easy to do like:
>
> public class OrganizationKey {
> /** ID. */
> private int areaId;
>
> /** Organization ID. */
> @AffinityKeyMapped
> private int organizationId;
>
> }
>
>
> Then I want to collocate the Employee with the Organization, I am not sure
> which one should be the AffinityKeyMapped field, OrganizationKey or
> organizationId ?
>
> public class EmployeeKey {
> private int id;
> /** ID. */
>
> /** Organization ID. */
> @AffinityKeyMapped
> private int organizationId;
>
> }
>
> or
>
> public class EmployeeKey {
> private int employeeId;
> /** ID. */
>
> /** Organization key. */
> @AffinityKeyMapped
> private OrganizationKey organizationkey;
>
> }
>
> thanks.
>
>
>
> --
> Sent from: http://apache-ignite-users.70518.x6.nabble.com/
>