Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Container-managed EntityManagerFactory instances need eager inflation #3009

Closed
ljnelson opened this issue May 11, 2021 · 0 comments · Fixed by #3018
Closed

Container-managed EntityManagerFactory instances need eager inflation #3009

ljnelson opened this issue May 11, 2021 · 0 comments · Fixed by #3018
Assignees

Comments

@ljnelson
Copy link
Member

In our JPA integration, it is possible that automatic DDL generation for a given persistence provider is set up deliberately or by default to be lazy. In such a case, if the first encounter with an EntityManager is from within a JTA-managed transaction, and the DDL action involves a DROP TABLE situation, and the table to be dropped doesn't exist (a very common scenario with throwaway/testing databases), then the transaction in which this occurs is rolled back and the application cannot run.

See #2630 as an example.

The solution to this problem is to ensure that container-managed EntityManagerFactory contextual references have a business method called on them (like, arbitrarily, isOpen(), which should of course return true) when the container comes up and before any user code has the opportunity to accidentally cause this to happen inside a transaction. This will cause the CDI proxy machinery to "inflate" the proxy and kick off what might be configured to be eager DDL generation (such as with eclipselink.deploy-on-startup and the like).

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
Archived in project
1 participant