When to Use EntityManager.clear()?
The articles explains it. Clearing the entity manager empties its associated cache, forcing new database queries to be executed later in the transaction. It’s almost never necessary to clear the entity manager when using a transaction-bound entity manager. I see two reasons to clear: when doing batch processing, in order to avoid having a giant … Read more