views:

211

answers:

1

Since I cannot do JOIN queries against the App Engine Datastore, I would like to denormalize my entity objects a little to include computed values, in effect creating something like a function-based index.

 @Persistent
 Employee manager;

 @Persistent
 // de-normalized stored join value
 Integer managerDepartmentCode;

This works fine, but I need to manually make sure that I refresh the computated values before persisting the object. Is there a better way to do that?

For example, can I annotate getters that would be used to get the computed values with @Persistent instead of fields (there would be no corresponding setter or field)?

@Persistent
Employee manager;

@Persistent
// de-normalized stored join value, calculated on the fly
Integer getManagerDepartmentCode(){
   return manager.getDepartmentCode();
}
+1  A: 

Could you put the logic into StoreCallback.jdoPreStore() or StoreLifecycleListener.preStore?

mlk