How to do this GQL query in JDO

Posted by TheDon on Stack Overflow See other posts from Stack Overflow or by TheDon
Published on 2010-03-18T05:13:19Z Indexed on 2010/03/18 5:21 UTC
Read the original article Hit count: 666

Filed under:
|
|
|
|

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?

© Stack Overflow or respective owner

Related posts about appengine

Related posts about jdo