Are both the parent and child persisted at the same time? If so, you can add
the child object as a child (not the Key) of the Parent object and call
makePersistent on the Parent.

On Thu, Feb 4, 2010 at 1:28 AM, Manny S <manny.m...@gmail.com> wrote:

> 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
> google-appengine-j...@googlegroups.com.
> To unsubscribe from this group, send email to
> google-appengine-java+unsubscr...@googlegroups.com<google-appengine-java%2bunsubscr...@googlegroups.com>
> .
> For more options, visit this group at
> http://groups.google.com/group/google-appengine-java?hl=en.
>



-- 
Ikai Lan
Developer Programs Engineer, Google App Engine
http://googleappengine.blogspot.com | http://twitter.com/app_engine

-- 
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 google-appengine-j...@googlegroups.com.
To unsubscribe from this group, send email to 
google-appengine-java+unsubscr...@googlegroups.com.
For more options, visit this group at 
http://groups.google.com/group/google-appengine-java?hl=en.

Reply via email to