On Mon, Feb 22, 2010 at 1:19 PM, Max Ross (Google) <maxr+appeng...@google.com> wrote: > > user-defined long-id keys are not quite as easily used. You either need to > commit to not letting the datastore generate ids for that kind or you need > to reserve a batch of ids using the DatastoreService.allocateIds method. > Otherwise you run the risk of a silent collision. There is no such risk > with user-defined string keys.
Right, but if the user has a natural key (long, String, whatever) they won't be using the generator anyways. There are plenty of natural long keys in the world... facebook userid being a popular one. FWIW, Objectify makes the distinction between ids of type Long, which can be null and thus autogenerated, and long (the primitive) which cannot be autogenerated. I really hadn't intended to plug Objectify here, really! > Valid point about renaming, but going back to the example I provided, the > datastore does not distinguish between inserts and updates. The only way > you can guarantee that an entity was inserted, and therefore the only way > you can guarantee the uniqueness of the name, is to use a user-defined key. > If you're mapping id to name it will be possible to create two entities with > the same name. It's of course up to you to decide how important this is to > defend against, but without the ability to provide your own id you wouldn't > get to make this choice, and without the ability to provide your own string > id you wouldn't be able to add some application-specific meaning to this > choice. I totally agree with you WRT user-defined vs generated values, I just don't see anything wrong with using the long id as a user-defined value. Just make sure you never ask for a generated one. Seems pretty straightforward. Jeff -- 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.