persistence icon indicating copy to clipboard operation
persistence copied to clipboard

Support @PersistenceContext injection in CDI SE and CDI/Servlet environment

Open hantsy opened this issue 4 years ago • 1 comments

Like Spring, add CDI decorations to provide injection for EntityManager and EntityMangerFactory for CDI SE and Servlet/CDI environment.

  • CDI SE, the application is bootstrapped by a CDI container, even the embedded tomcat/jetty can be declared as CDI beans.
  • Servlet/CDI, the application is war deployed into a standard servlet container that enabled CDI support via a servlet Listener.

I think there are some approaches already support this, such as Apache DeltaSpike and Quarkus, Helidon etc.

hantsy avatar Apr 17 '21 04:04 hantsy

I'd go one step further and not just add some "decorations", but make the CDI way the primary way and deprecate the existing annotations. See https://github.com/eclipse-ee4j/jpa-api/issues/377

arjantijms avatar Sep 04 '22 20:09 arjantijms

See https://github.com/jakartaee/persistence/issues/377

Yeah, I think this and #377 are essentially the same issue. Or at least the solution would be the same.

gavinking avatar Aug 11 '23 17:08 gavinking