views:

254

answers:

1

According to JDO, you can use PersistenceManager.getObjectsById to load multiple entity instances by their object id.

What kind of Collection does one need to use here? A Google Data Store Key does not work as object id.

A: 

Not a direct answer, by as an alternative to getObjectsById, it seems that you can use a JDOQL query to load multiple entities by key:

public List getById(List keys) {
   Query q = pm.newQuery(
      "select from " + Book.class.getName() + " where :keys.contains(key)");
   return (List) q.execute(keys);
}

Apparently, this query is optimized to use an efficient low-level bulk API.

The order of the keys does get lost though, so you will have to re-sort the result in Java land.

Thilo