Well, if the ids for entities sharing the same parent were not unique for a particular kind, it would be a very serious problem. ;) Check out some of the articles for more details on how the datastore works: http://code.google.com/appengine/articles/datastore/overview.html
You might want to include the parent entity's id as well. If you know the parent type and id, and the child's type and id you can rebuild the key for an entity. Check KeyFactory for more details. http://code.google.com/appengine/docs/java/datastore/creatinggettinganddeletingdata.html#Getting_an_Object_By_Key http://code.google.com/appengine/docs/java/javadoc/com/google/appengine/api/datastore/KeyFactory.html Robert On Thu, Nov 18, 2010 at 22:44, Riley Lark <[email protected]> wrote: > And 3: can I assume that ids will be unique within an entity group and Kind, > or are there no guarantees at all? > > On Thu, Nov 18, 2010 at 9:23 PM, Riley <[email protected]> wrote: >> >> I have a datastore full of entities. They are all in an entity group with >> many other entities - maybe 1000 per group. I am using keys and parent keys >> to keep them organized: >> @PersistenceCapable(detachable = "true") >> public class Assessment >> { >> @SuppressWarnings("unused") >> @Persistent >> @Extension(vendorName = "datanucleus", key = "gae.parent-pk", value = >> "true") >> private Key parentKey; >> @PrimaryKey >> @Persistent(valueStrategy = IdGeneratorStrategy.IDENTITY) >> private Key key; >> ... >> >> However, to communicate with the client, I've been using key.getId() to >> get a numeric identifier. I've been assuming that each key would have a >> different id, but have recently noticed that this is a bad assumption! Many >> of my entities share an ID! Unfortunately, I noticed this just a couple of >> days after opening my app to beta testers, so I have real data on the line. >> >> 1: How can I ensure that every entity gets a unique id? Do I have to >> implement my own id generator? >> 2: Now that I have many entities with the same id (but different keys) is >> there any way to efficiently transmit something that uniquely identifies >> each entity? >> Thanks for any help or advice! >> >> -- >> You received this message because you are subscribed to the Google Groups >> "Google App Engine" 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?hl=en. > > -- > You received this message because you are subscribed to the Google Groups > "Google App Engine" 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?hl=en. > -- You received this message because you are subscribed to the Google Groups "Google App Engine" 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?hl=en.
