Hello, I am working on legacy hibernate application and noticed that post querying the selects of huge data, the application code is flushing and clearing secondary cache. Now, the subsequent request is again taking the same time as first request.
Let me know if flush and clear of EM also clears secondary cache?
A query will flush the entity manager because there might be pending changes that need to be synchronized prior to the query execution. That happens during FlushModetype.AUTO flush strategy which is used by default.
As for 2nd-level cache, only a native SQL query can invalidate the Query cache. If you’re talking about the entity or collection caches, then these regions are not cleared based on query executions.