Hello,
we have following situation:
The EntityManagerFactory is always opened and won't be closed.
Thread A with its own EntityManager persists entities and commits the entities successfully.
Thread B runs afterwards also with its own EntityManager and tries to load the persisted entities by a query.
But there are not any results available.
We debugged the problem.
Thread B executes the query and prints the results to the console, but there are not results. After that the thread stops at a debug break point.
We steps over the next statement which also executes the identical query again. And we get the expected results. Why?
It is also possible to insert a Thread.sleep(1000) before executing the query, in this case we get always the expected results.
The problem does only occur, if we have a certain persistence constellation of a use case. If there are more or less persistence operations then the problem does not happen.
Can you imagine or explain this timing problem?