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