The question is specific to caching in Persistent Context(L1) and not to second level cache.
I want to know why entity in the cache of Persistent context are not refreshed on selection/re-loading of entity using JPQL.
Explanation of question using example:
- Start of transaction A
- Load entity A in the persistent context in transaction A.
- Some other processing in transaction A. But the loaded entity is not modified. At the same time, the same entity is modified and committed in another transaction B i.e. in another persistent context.
- Reload of entity A in transaction 1 using JPQL (select clause). Entity A has stale attributes.
I verified in the logs that query was fired. Then why was entity A not refreshed?