The GAE-JDO docs suggest it is possible to retrieve parent keys from child keys:
Note also that a key's string representation is not encrypted: a user can decode the key string to extract its components, including the kinds and identifiers of the entity and its ancestors.
REF: "Entities, Properties, and Keys"
I am generating keys using the following:
@PrimaryKey
@Persistent(valueStrategy = IdGeneratorStrategy.IDENTITY)
@Extension(vendorName = "datanucleus", key = "gae.encoded-pk", value = "true")
private String id;
When inspecting the datastore, my entity keys look like the following:
parent.id = agpzfnZpdmVlbGFichQLEgdTZXNzaW9uGICAgICgwMsIDA
child1.id = agpzfnZpdmVlbGFiciYLEgdTZXNzaW9uGICAgICgwMsIDAsSBVN0YWdlGICAgICAwK8KDA
...
(where Parent has children of type Child). So, what I'm looking for is a GWT function like this:
String getParentIdFromChildId(String childId) {
String parentId = ...
return parentId;
}
so that from the client (GWT) I can reference the child object (by first finding its parent):
Child child = data.getParent(getParentIdFromChildId(childId)).getChild(childId);
I could solve this problem by also keeping track of the parent id, but if the parent information is already embedded in the child id, this is inefficient.
Thanks in advance.
~Owen