|
18 | 18 | import static org.springframework.data.jpa.repository.config.BeanDefinitionNames.*;
|
19 | 19 |
|
20 | 20 | import jakarta.persistence.Entity;
|
| 21 | +import jakarta.persistence.EntityManager; |
21 | 22 | import jakarta.persistence.EntityManagerFactory;
|
22 | 23 | import jakarta.persistence.MappedSuperclass;
|
23 | 24 | import jakarta.persistence.PersistenceContext;
|
|
45 | 46 | import org.springframework.beans.factory.config.BeanDefinition;
|
46 | 47 | import org.springframework.beans.factory.config.ConfigurableBeanFactory;
|
47 | 48 | import org.springframework.beans.factory.config.ConfigurableListableBeanFactory;
|
| 49 | +import org.springframework.beans.factory.config.RuntimeBeanReference; |
48 | 50 | import org.springframework.beans.factory.support.AbstractBeanDefinition;
|
49 | 51 | import org.springframework.beans.factory.support.BeanDefinitionBuilder;
|
50 | 52 | import org.springframework.beans.factory.support.BeanDefinitionRegistry;
|
@@ -138,7 +140,8 @@ public void postProcess(BeanDefinitionBuilder builder, RepositoryConfigurationSo
|
138 | 140 | Optional<String> transactionManagerRef = source.getAttribute("transactionManagerRef");
|
139 | 141 | builder.addPropertyValue("transactionManager", transactionManagerRef.orElse(DEFAULT_TRANSACTION_MANAGER_BEAN_NAME));
|
140 | 142 | if (entityManagerRefs.containsKey(source)) {
|
141 |
| - builder.addPropertyReference("entityManager", entityManagerRefs.get(source)); |
| 143 | + builder.addPropertyValue("entityManager", |
| 144 | + new RuntimeBeanReference(entityManagerRefs.get(source), EntityManager.class)); |
142 | 145 | }
|
143 | 146 | builder.addPropertyValue(ESCAPE_CHARACTER_PROPERTY, getEscapeCharacter(source).orElse('\\'));
|
144 | 147 | builder.addPropertyReference("mappingContext", JPA_MAPPING_CONTEXT_BEAN_NAME);
|
@@ -235,14 +238,10 @@ private void registerSharedEntityMangerIfNotAlreadyRegistered(BeanDefinitionRegi
|
235 | 238 | String entityManagerBeanRef = getEntityManagerBeanRef(config);
|
236 | 239 | String sharedEntityManagerBeanRef = lookupSharedEntityManagerBeanRef(entityManagerBeanRef, registry);
|
237 | 240 |
|
238 |
| - // TODO: Remove once Cannot convert value of type 'jdk.proxy2.$Proxy129 implementing |
239 |
| - // org.hibernate.SessionFactory,org.springframework.orm.jpa.EntityManagerFactoryInfo' to required type |
240 |
| - // 'jakarta.persistence.EntityManager' for property 'entityManager': no matching editors or conversion strategy |
241 |
| - // found is fixed. |
242 |
| - /*if (sharedEntityManagerBeanRef != null) { |
| 241 | + if (sharedEntityManagerBeanRef != null) { |
243 | 242 | entityManagerRefs.put(config, sharedEntityManagerBeanRef);
|
244 | 243 | return;
|
245 |
| - } */ |
| 244 | + } |
246 | 245 |
|
247 | 246 | String entityManagerBeanName = "jpaSharedEM_" + entityManagerBeanRef;
|
248 | 247 |
|
|
0 commit comments