Reputation: 1759
When migrating the app from M/S datastore to HRD there are certain pitfalls to avoid. I had a question on one such specific area where it says "Entity ids of the same Kind are not always unique".
To explain it further here's an example.
The 3 classes are:
public class Customer {
@PrimaryKey
@Persistent(valueStrategy = IdGeneratorStrategy.IDENTITY)
private Key id;
@Persistent
private String name;
}
public class Contact {
@PrimaryKey
@Persistent(valueStrategy = IdGeneratorStrategy.IDENTITY)
private Key id;
@Persistent
private String name;
@Persistent
private Key customerId;
}
public class Address {
@PrimaryKey
@Persistent(valueStrategy = IdGeneratorStrategy.IDENTITY)
private Key id;
@Persistent
private String address;
@Persistent
private Long customerId;
}
All the entities are root entities.
Now when we migrate what will happen to customerId in Contact and Address entities? Will they still work or do we need to do anything special with them before migration?
Thanks!
Upvotes: 0
Views: 313
Reputation: 14185
What you are referring to is to do with how keys are built. An entity's key will be made up from:
<-- this allows ids to be non-unique within a kind
key_name
OR id
So for a key to be unique, any one of those parts could change. Within a single kind, within a single namespace within your app, the only time ids may not be unique is when you have set a parent
for that entity.
This means all your root entities as defined, will have unique ids/names.
If you need to guarantee that assigned ids are unique within a kind even across entities with an ancestor hierarchy, you could;
Upvotes: 1