1

The Javadoc for PersistenceAnnotationBeanPostProcessor states, "If you prefer the Java EE server's own EntityManager handling, specify entries in this post-processor's 'persistenceContexts' map." This causes PersistenceAnnotationBeanPostProcessor to always obtain EntityManagers via JNDI lookups instead of using an EntityManagerFactory. I want this behavior because my Java EE container (Wildfly 10) provides a container-managed, transaction-scoped EntityManager via the JNDI lookup. This configuration works well for injecting EntityManager fields annotated with @PersistenceContext in my Spring @Services.

However, I'm running into a problem with my JpaRepository beans: I can't seem to get Spring Data JPA to want anything other than an EntityManagerFactory. Is there a way to inject Wildfly's container-managed EntityManager into my JpaRepository instances? I don't want to use Wildfly's EntityManagerFactory because it vends application-managed EntityManagers...

gilby
  • 232
  • 2
  • 13

0 Answers0