DATACMNS-1580 - Fix EntityManagerFactory lookup in BeanDefinitionUtils.
We now use a set to collect all the EntityManagerBeanDefinitions returned from the application context. Spring Framework recently changed the bean names by type lookup behavior to also consider the return type of a factory bean so that we now see Spring defined EntityManagerFactory beans twice as we look them up via the EMF interface as well as via AbstractEntityManagerFactoryBean. Using a set as the target unifies them into one logical bean definition again.
This commit is contained in:
@@ -18,6 +18,8 @@ package org.springframework.data.jpa.util;
|
||||
import static java.util.Arrays.*;
|
||||
import static org.springframework.beans.factory.BeanFactoryUtils.*;
|
||||
|
||||
import lombok.EqualsAndHashCode;
|
||||
|
||||
import java.util.ArrayList;
|
||||
import java.util.Collection;
|
||||
import java.util.Collections;
|
||||
@@ -93,7 +95,7 @@ public class BeanDefinitionUtils {
|
||||
public static Collection<EntityManagerFactoryBeanDefinition> getEntityManagerFactoryBeanDefinitions(
|
||||
ConfigurableListableBeanFactory beanFactory) {
|
||||
|
||||
List<EntityManagerFactoryBeanDefinition> definitions = new ArrayList<EntityManagerFactoryBeanDefinition>();
|
||||
Set<EntityManagerFactoryBeanDefinition> definitions = new HashSet<EntityManagerFactoryBeanDefinition>();
|
||||
|
||||
for (Class<?> type : EMF_TYPES) {
|
||||
|
||||
@@ -120,7 +122,7 @@ public class BeanDefinitionUtils {
|
||||
* @param definitions
|
||||
*/
|
||||
private static void registerEntityManagerFactoryBeanDefinition(String name,
|
||||
ConfigurableListableBeanFactory beanFactory, List<EntityManagerFactoryBeanDefinition> definitions) {
|
||||
ConfigurableListableBeanFactory beanFactory, Collection<EntityManagerFactoryBeanDefinition> definitions) {
|
||||
|
||||
BeanDefinition definition = beanFactory.getBeanDefinition(name);
|
||||
|
||||
@@ -168,6 +170,7 @@ public class BeanDefinitionUtils {
|
||||
* @author Oliver Gierke
|
||||
* @author Thomas Darimont
|
||||
*/
|
||||
@EqualsAndHashCode
|
||||
public static class EntityManagerFactoryBeanDefinition {
|
||||
|
||||
private final String beanName;
|
||||
|
||||
Reference in New Issue
Block a user