Hi Chris,
Many thanks for reading the testcase and your detailed explanation.
I am convinced that the cache can no longer be trusted after an update
query has run, and I can understand that the update query did not
refresh the entities in the cache. I also understand that what I am
seeing in the log file is not necessarily happening in the sequential
order that I would expect.
Therefore I am happy with the fact that EntityManager fetches those
entities once again after an update query, even after it had fetched
them before for a result list.
I am making multiple fruitless efforts to not touch the related parent
entity more than once with FetchType.LAZY and by not reading them as
an entity but reading only its foreign key value via the different
mapping that I created for that purpose.
What really stands out in that testcase and what I fail to understand
is that Entitymanager absolutely consistently fetches the same parent
entity, after the update queries have already run, multiple times,
e.g. 35 times in a row, exactly as many times as I read its children
even while I am not accessing the parent at all. This is in step 2)
where no update queries are run, and where entities are updated only
via their setter methods. I really don't know what would explain this
behavior and that leads me to think it is a bug.
Regards
Bernard