Question

Since there is no way to join tables using Google App Engine datastore, I loop over a list of entities and look up the related entities one-by-one using the foreign key value.

for (Employee staff: staffList){
   Employee manager = pm.getObjectById(Employee.class, staff.getManagerId());
}    

There is a good chance that I will be needing the same referenced entity more than once, and I do not want to go to the datastore twice for the same entity.

Is there some kind of session cache that I can enable to eliminate the duplicate lookups, or do I have to roll my own?

Was it helpful?

Solution

JDO the spec does mandate caching of instances within a PersistenceManager, according to datanculeus, who provided help with the app engine JDO functionality:

link to datanucleus cache page

However, I know that there ares still some things missing from the appengine implementation, as mentioned here:

app engine unsupported features

The good news is that caching doesn't seem to be on that list. The bad news is that I couldn't find confirmation that level 1 caching is implemented. It shouldn't be that hard to test though - time your code getting 100 different entities, then time it getting the same entity 100 times.

Licensed under: CC-BY-SA with attribution
Not affiliated with StackOverflow
scroll top