You might want to have a look at this:

http://code.google.com/appengine/docs/java/javadoc/com/google/appengine/api/datastore/DatastoreService.html#allocateIds(com.google.appengine.api.datastore.Key,
java.lang.String, long)

You can specify a parent and allocate IDs. The only caveat is that these may
not be guaranteed to be sequential: just unique.

On Wed, Aug 25, 2010 at 4:24 AM, markus <[email protected]> wrote:

> Hello all!
>
> I have a datastore class "User", which has a property key of type Key
> as its primary key.
>
> Now, I want to store objects of type "Result" in the datastore, as
> children of the User in an unowned relationship. Each result has a
> property key of type Key as its primary key as well.
>
> For creating the key of the child, I currently use the
> Key.getChild(String kind, String name) method on the parent key (see
>
> http://code.google.com/appengine/docs/java/javadoc/com/google/appengine/api/datastore/Key.html#getChild%28java.lang.String,%20java.lang.String%29
> ),
> specifically like this:
>
> Key key = user.getKey().getChild(Result.class.getSimpleName(),
> UUID.randomUUID().toString());
>
> The problem is, I'm quite sure that the UUID class doesn't guarantee
> uniqueness in a distributed setting like GAE. Is there a way to
> generate a unique name here, or preferably let the datastore handle
> uniqueness? Like a Key.getChild(String kind) method.
>
> Regards,
> Markus
>
> --
> 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
Blog: http://googleappengine.blogspot.com
Twitter: http://twitter.com/app_engine
Reddit: http://www.reddit.com/r/appengine

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