I am missing something simple here but can anyone point me to how I can set
the child key before making the parent data persistent...(in a
unidirectional one to one relationship)
I create the parent data and the child data
parentdata pdata = new parentdata('x','y', 'z');
pdata.setKey(null);
childdata child = new childdata('A');
pdata.setChild(child);
Now, I would like to set the child key as parent key + mystring
When I try,
String strparentKey = KeyFactory.keyToString(pdata.getKey());
String strchildKey = strparentKey + "details";
Key childKey = KeyFactory.stringToKey(strchildKey);
it gives me an error as the parent data does not have a key yet (cause is
null)
In this case the key of the parent is generated only when I persist. But I
need to set the child key before I make it persistent. My application cannot
generate an unique app id and I rely on the datastore to do it. As far as I
can tell the KeyFactory.Builder does not have an option to generate unique
keys and relies on the app to provide it and so I cant use that either.
Any help would be appreciated...
Manny
--
You received this message because you are subscribed to the Google Groups
"Google App Engine for Java" group.
To post to this group, send email to [email protected].
To unsubscribe from this group, send email to
[email protected].
For more options, visit this group at
http://groups.google.com/group/google-appengine-java?hl=en.