Describe the bug
Injected test EntityManager during JUnit tests seems to be shared across threads which causes random errors.
To Reproduce
Steps to reproduce the behavior:
- In a test, use EntityManager to write in DB (same jpa unit) in app CDI classes, from at least 2 different threads
- Several errors are possible, example:
java.lang.IllegalStateException: org.hibernate.TransientPropertyValueException: object references an unsaved transient instance
Expected behavior
EntityManager instances should be per unit and per thread, like in a CDI app server (request scoped?)
not just per persistent unit
Additional context
JDK 17 / linux and macos
Describe the bug
Injected test EntityManager during JUnit tests seems to be shared across threads which causes random errors.
To Reproduce
Steps to reproduce the behavior:
Expected behavior
EntityManager instances should be per unit and per thread, like in a CDI app server (request scoped?)
not just per persistent unit
Additional context
JDK 17 / linux and macos