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 EntityManager
s 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 @Service
s.
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 EntityManager
s...