You can use DatastoreService.allocateIds() to get a range of unique keys that you can then assign to the children. The kind name can be any old String - not just an existing kind. This method does not guarantee the ids will be sequential but they will be unique.

If you really need sequential ids you can use memcache's atomic increment method. If the value is not found in memcache you can do a query to find the maximum sequence number in the datastore and use the memcache increment method that allows you to specify an initial missing value atomically.

John

On 30 Sep 2010, at 17:28, Fred wrote:

Hi Group,

I know key ids are only unique across entity groups so what GAE + JDO
gives me is:
/Parent[1]/Child[1]
/Parent[1]/Child[2]
/Parent[1]/Child[3]

/Parent[2]/Child[1]
/Parent[2]/Child[2]

/Parent[3]/Child[1]

etc.

What I need to achieve (aka implement) is a way to assign keys in the
following fashion:
/Parent[1]/Child[1]
/Parent[1]/Child[2]
/Parent[1]/Child[3]

/Parent[2]/Child[4]
/Parent[2]/Child[5]

/Parent[3]/Child[6]

etc... so child ids are in sequence across entity groups (or at least
unique). Does anyone have experience with this or any thoughts on how
to go about it in a secure fashion?
I can't seem to come up with a secure way of doing this, but don't
want to give up on it because it would give my use case a lot of
querying power.

Hope someone can help.
Thanks in advance,
Fred


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


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