Probably you did not retrieve the Key of the stored object correctly, or the error/bug is while storing the object. I do the same - convert Key to Long or String when storing relationship between entities, but I never got 0 as the generated Key.
Vaclav On Feb 17, 12:15 am, Clint <clintandrewh...@gmail.com> wrote: > I'm not sure what I'm doing wrong here. > > I'm persisting an object with a key created using a unique string, in > this case the user id. However, to make things more URI friendly, I'm > using the Key.getId() of these objects to serve as a unique id (uid). > > The first entity I save has key.getId() == 0. When I later attempt to > recover this entity, using a Key created by KeyFactory: > > // Key ID for the object being retrieved is 0. > AuthorDO.uidToKey("0"); > > public static Key uidToKey(String uid) { > long keyId = Long.parseLong(uid); > return KeyFactory.createKey(AuthorDO.class.getSimpleName(), > keyId); > } > > I get an illegal argument exception: > > java.lang.IllegalArgumentException: id cannot be zero > at > com.google.appengine.api.datastore.KeyFactory.createKey(KeyFactory.java: > 44 > at > com.google.appengine.api.datastore.KeyFactory.createKey(KeyFactory.java: > 31) > at com.sageek.quotebook.data.dao.jdo.AuthorDO.uidToKey(AuthorDO.java: > 214) > > The id is 0, according to the key that was created by the datastore. > Where is this error coming from? What am I doing wrong? -- 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.