Reputation: 613
I have existing entity in datastore. I can find it Admin Console by attribute query e.g.:
SELECT * FROM UserEntry where email = '[email protected]'
and also query it by encoded key string, e.g.:
SELECT * FROM UserEntry where __key__ = KEY('cy1hcHByIAsSCVVzZXJFbnRyeM')
However, when I query the entity by unencoded key, it is not found:
SELECT * where __key__ = KEY('UserEntry','[email protected]')
From former queries I can verify that the key is correct and the same query works for other entities of the same type.
I experience the same behavior when I try to access the entity via JDO API:
pm.getObjectById(UserEntry.class, "[email protected]");
This code results in following exception:
javax.jdo.JDOObjectNotFoundException: Could not retrieve entity of kind UserEntry with key UserEntry("[email protected]")
How did this happen? How can I resolve this issue and avoid it in the future?
Upvotes: 0
Views: 360
Reputation: 16890
Off-line we discovered that the urlsafe key string encodes for a username with a space added, as if it encoded KEY('UserEntry','[email protected] ')
. That seems an input validation bug in the program.
Upvotes: 2
Reputation: 126
Is the email property your PK on the Entity? Because if it is not, querying for it doen not make sense. Once you post your first query with the email as a ordinary property, I assume that it's not repeated on your PK, so you can not query using it on Key(type,email).
After getting the entity on admin console, click on key property to be certain that the email is part of the key.
Upvotes: 0