Using google appengine 1.3.0 w/ java and jdo...
While trying to write JDO querys for 1-to-many owned relationships, I came across a non-JDO concept that I thought was really smart. Ancestor Querys. The appengine.api.datastore.Query interface allows for scoping of a query using the parent Key.
Unfortunately the results from the query are 'Entity' objects with property lists. Is there a util in the apis that will convert one of these Entity objects into my JDO object or even a simple DTO bean (that matched my JDO object)?
I've taken a crack a brute forcing it with the code below but don't like the double lookup.
PersistenceManager pm;
DatastoreService datastore = DatastoreServiceFactory.getDatastoreService();
List<MyObject> results;
com.google.appengine.api.datastore.Query query = new Query( "MyObject", KeyFactory.stringToKey( parentId ) );
query.addFilter("rank", Query.FilterOperator.GREATER_THAN_OR_EQUAL, minRank );
query.addSort("rank");
query.setKeysOnly();
for (Entity anEntity : datastore.prepare(query).asIterable()) {
results.add( pm.getObjectById( MyObject.class, anEntity.getKey() ) );
}