Saturday, July 25, 2009

Fix: Google App Engine Java: Field "X" does not exist in class B or is not persistent

Just in case it help anybody with a similar problem:

I'm using JDO on Google App Engine, and had a problem with a javax.jdo.Query query when searching for all items with a particular key. In my structure, class Item has field Key listKey, and class Task extends Item. Executing a query for Task specifying the field listKey kept getting the exception
Field "listKey" does not exist in class Task or is not persistent
even though it definitely had the field, and I could see the data with the correct field name in the data explorer. The only fix that worked was removing the field from the Item class and adding it to the Task class.

Also, to use a Key in the query, I had to add this to the query:
query.declareImports("import com.google.appengine.api.datastore.Key");

No comments:

Post a Comment