Got it. Thanks again Ikai.
Manny

On Thu, Feb 18, 2010 at 12:16 AM, Ikai L (Google) <[email protected]> wrote:

> There should be with KeyFactory's builder, but you may not want to go
> there:
>
>
> http://code.google.com/appengine/docs/java/javadoc/com/google/appengine/api/datastore/KeyFactory.Builder.html
>
>
> On Sun, Feb 14, 2010 at 10:16 PM, Manny S <[email protected]> wrote:
>
>> Thanks Ikai,
>> I am doing it the way you described and it does work. Just wanted to know
>> if there is a way to set the child key explicitly as parent + "const
>> string". But I understood that will not work with datastore generated keys
>> since the parent needs to be persisted in order to get a key. Apologies for
>> the naive question :).
>> Manny
>>
>> On Fri, Feb 12, 2010 at 1:41 AM, Ikai L (Google) <[email protected]>wrote:
>>
>>> 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 <[email protected]> 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
>>>> [email protected].
>>>> To unsubscribe from this group, send email to
>>>> [email protected]<google-appengine-java%[email protected]>
>>>> .
>>>> 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
>>> [email protected].
>>> To unsubscribe from this group, send email to
>>> [email protected]<google-appengine-java%[email protected]>
>>> .
>>> For more options, visit this group at
>>> http://groups.google.com/group/google-appengine-java?hl=en.
>>>
>>
>>  --
>> 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]<google-appengine-java%[email protected]>
>> .
>> 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
> [email protected].
> To unsubscribe from this group, send email to
> [email protected]<google-appengine-java%[email protected]>
> .
> For more options, visit this group at
> http://groups.google.com/group/google-appengine-java?hl=en.
>

-- 
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.

Reply via email to