Skip to content

EntityManager issue in multithreaded tests #552

Description

@amasson88

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:

  1. In a test, use EntityManager to write in DB (same jpa unit) in app CDI classes, from at least 2 different threads
  2. 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

Activity

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

Labels

No labels
No labels

Projects

No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions