With l2 cache turned on (by setting "openjpa.DataCache" property to "true" in persistence.xml) we observed following behavior:
Lets say we have model Person <-> Address(LAZY, owner). We create a new instance of Person and Address. Since Person is non-owing side of relation, we set Person instance in Address but don't set Address instance in Person. We then persist both Person and Address instance. Later when we query Person entity by using EntityManager.find method the returned instance of Person doesn't have Address field set. This field doesn't get set even if we query Address entity.
It appears that Person entity that was created when we persisted gets cached and it doesn't get refreshed when we query for that instance.
I have looked at defect https://issues.apache.org/jira/browse/OPENJPA-2285 and applied that fix to open jpa 2.2.2 but I still see the same behavior. I did some debugging and found that PCDataImpl.isLoaded method always returns true for the 'address' field and hence it looks up in its internal "_data" object array for value, which has null for 'address' field. In effect the check of the loadedFieldsAfter and loadedFieldsBefore introduced in OPENJPA-2285 doesn't trigger and cache is never updated.
I have verified that this is indeed a cache problem by evicting the "Person" class from datacache (using EntityManagerFactory.getCache().evict(Person.class) method) and making sure that further queries for that Person instance returns address when we try to access that field.