A custom JPA mapper class has a method:
removeUser()
1. execute \'DELETE\' HQL query to remove user
2. call getEntityManager().flush();
3. call getEntityMan
Yeas, it's exactly depends on the architecture style of the platform as documentation points.
As you see depends on the cases, architecture and style for your platform. Directly for your method - it's not a good practice to flush and clear cache per method, it's a anti pattern method.
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: