Fix auto-configuration to apply a shared container entity manager instance for GraphQLJPASchemaBuilder #380
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
To fix intermittent incorrect empty query results due to Hibernate query result list containing proxied entities when executing query requests concurrently.
The GraphQLJPAQueryBuilder was not using the Shared Entity Manager proxy provided by Spring ORM. Instead, it was configured using a static instance backed by non-thread safe Hibernate Session created by the entity manager factory method.
A Spring shared EntityManager will behave just like an EntityManager fetched from an application server's JNDI environment, as defined by the JPA specification. It will delegate all calls to the current transactional EntityManager already attached to a thread per transaction, if any; otherwise it will fall back to a newly created EntityManager per operation request.
The functional tests worked fine, but not concurrently. It also worked in Hibernate 5 by luck and stopped working in Hibernate 6 after upgrade to Spring Boot 3