Yeas, it's exactly depends on the architecture style of the platform as documentation points.
- For example if in your application EM is thread's associated, then one of
the solutions for transaction management is to implement Session-Per-Request pattern which starts a transaction on each start of user's request and commit & clear the cache in each end of the request in order to prevent dirty reads. This is just a simple example
- Other example is in a SOA platform. For each service could be also open a transaction in the beginning and commit it at the end with clearing (in case same EM is used by other service and avoiding of dirty reads is required)
- I will replay the previous two common cases - batch processing one and bypassing in all possible cases the EM. So in this case queries will be forced to query from the DB , not from the cache.
- You should know that you work with L1 and L2 caches and L1 is the cache cleared by EM. When you reads huge set of data (should be not the case)( then also clearing is required in a period.
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.