What we would like to do is be able to cache relationship fields so that the first time the relationship is accessed, there will be a join against the owner id. On subsequent calls, the relationship would be cached with the id. The id would be used to look up in the cache and either pass back the object, load it by id, and cache it. The relationship is removed when a field is made dirty.
I have augmented the StateManager to accomplish this but I am not sure I have gone down the best path. I am submitting the enclosed augmented JDOStatemanager to show where I trying to go with this. One thing to look at it that I have to use the OID to get the class of the object id i have so that i can create hallow pms with statemanagers.
it is configurable via the cacheRelationships variable. <persistence-property name="datanucleus.CacheRelationships" value="false"/>