I've written a tool for my IT staff to use to manage data issues for a software suite that is being phased out. I've been fighting with caching in EclipseLink through the entire process, and though I have found a way to get the behavior I need, I can't believe it is so much work.
For the longest time, I believed I was fighting with the shared (L2) cache, as it turns out I'm fighting the isolated (L1) cache.
The only solution I have found that works is to call entityManager.clear() at the beginning of every query.
Since I'm working with a data set which is shared with non-Java software, I need ALL read caching disabled, globally. What I'd prefer is for the cache to be updated, rather than erased on every read. In other words, I like the query to bypass all caches, and update them with the results, rather than wipe out all (potentially unrelated) cached results. Further, I need writes to operate on pessimistic assumptions (i.e. verify no other data has been changed since the data was read into the cache).
Is there a way I can get the behavior I am looking for globally?