@Primary not working for LocalContainerEntityManagerFactoryBean #24097
Labels
in: core
Issues in core modules (aop, beans, core, context, expression)
status: duplicate
A duplicate of another issue
Present in Spring 5.1.2.RELEASE
Created 2 beans of type
LocalContainerEntityManagerFactoryBean
, annotated one with@Primary
. Neither EntityManager proxy (of type SharedEntityManagerCreator$SharedEntityManagerInvocationHandler) gets marked as primary when trying to get it through @AutowiredSeems related to issue #22675
Beans goes through DefaultListableBeanFactory.isPrimary() with beanName as "org.springframework.orm.jpa.SharedEntityManagerCreator#0" and "org.springframework.orm.jpa.SharedEntityManagerCreator#1". Both do not start with a factory dereference prefix, so isPrimary() does not check the Bean's parent BeanFactory for the @primary annotation, so the running application cannot decide which to autowire.
The text was updated successfully, but these errors were encountered: