How to do this GQL query in JDO
- by TheDon
I have about 50k entities stored in appengine. I am able to look up an individual record via the GQL admin interface with a query like:
SELECT * FROM Pet where __key__ = KEY( 'Pet','Fido')
But I'm having trouble figuring out how to do a batch version of this via JDO. Right now I have this:
PersistenceManager pm = ...;
for(Pet pet : pets) {
for(String k : getAllAliases(pet)) {
keys.add(KeyFactory.createKeyString(Pet.class.getSimpleName(), k));
}
}
Query q = pm.newQuery("select from " + Pet.class.getName() + " where id == :keys");
List<Pet> petlist = (List<Pet>) q.execute(keys);
But though 'Fido' works in the GQL case, it returns nothing when I use that Java + JDO code. What am I doing wrong?