When you call EntityManager.flush (), will it also clear the second cache?

When calling EntityManager.flush (), will it also hide the second level cache? I tried Googling, and I also tried flushing it, and it looks like it is, but it would be nice if it was confirmed.

Edit: now it doesn't seem like it is clearing the second level cache.

+7
source share
2 answers

JPA does not have a second level cache concept (it is not part of the specification). Thus, the behavior of the second level cache is completely dependent on the JPA provider. What do you use Hibernate, EclipseLink, OpenJPA?

Update: I am partially fixed, JPA 2.0 introduces several options for managing the use of a second level cache (for example, @Cachable )

+1
source

The L2 cache should (by default, in any reasonable JPA implementation) not be updated upon commit, but this is not provided for by the JPA2 specification, so you do not understand the implementation features, DataNucleus, of course, only updates it upon commit. If the cache of the second level was updated in a flash, and then these changes to objects bounce back, this leads to the reading of potential invalid / volatile data. Some may allow this as an option.

0
source

All Articles