# A little question about EntityManager Flush and Clear

**URL:** <https://discourse.hibernate.org/t/a-little-question-about-entitymanager-flush-and-clear/381>\
**Category:** Hibernate ORM\
**Created:** [March 19, 2018, 9:11am UTC](https://discourse.hibernate.org/t/a-little-question-about-entitymanager-flush-and-clear/381 "2018-03-19T09:11:50Z")\
**Posts on this page:** 2\
**Page:** 1

<div class="post-metadata">

**Author:** ![alierainy123](https://avatars.discourse-cdn.com/v4/letter/a/b5ac83/32.png) [@alierainy123](https://discourse.hibernate.org/u/alierainy123)\
**Post date:** [March 19, 2018, 9:11am UTC](https://discourse.hibernate.org/t/a-little-question-about-entitymanager-flush-and-clear/381/1 "2018-03-19T09:11:50Z")

</div>

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?

Thanks.

---

<div class="post-metadata">

**Author:** ![vlad](https://yyz1.discourse-cdn.com/flex035/user_avatar/discourse.hibernate.org/vlad/32/658_2.png) [@vlad](https://discourse.hibernate.org/u/vlad)\
**Post date:** [March 19, 2018, 9:14am UTC](https://discourse.hibernate.org/t/a-little-question-about-entitymanager-flush-and-clear/381/2 "2018-03-19T09:14:53Z")

</div>

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`](https://vladmihalcea.com/how-does-the-auto-flush-work-in-jpa-and-hibernate/) 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.
