From 7f61bce4d0e1287df90351cfb426ea8836f236b7 Mon Sep 17 00:00:00 2001
From: Pavel Gnusin
Date: Wed, 16 Jun 2021 17:21:57 +0300
Subject: [PATCH] Look up bean merged bean definitions in `Repositories`.
MIME-Version: 1.0
Content-Type: text/plain; charset=UTF-8
Content-Transfer-Encoding: 8bit
We now look up bean definitions for repositories using BeanFactory.getMergedBeanDefinition(…) to consider parent-child relationships across application contexts.
As we iterate through bean definitions considering ancestors we need to allow parent bean definitions. Previously, we obtained the bean definition from the child context and since the bean was inherited from the parent, the child context cannot provide a bean definition.
Closes #2383
Original pull request: #2384.
---
.../springframework/data/repository/support/Repositories.java | 2 +-
1 file changed, 1 insertion(+), 1 deletion(-)
diff --git a/src/main/java/org/springframework/data/repository/support/Repositories.java b/src/main/java/org/springframework/data/repository/support/Repositories.java
index fe7cec646..e3316aded 100644
--- a/src/main/java/org/springframework/data/repository/support/Repositories.java
+++ b/src/main/java/org/springframework/data/repository/support/Repositories.java
@@ -306,7 +306,7 @@ public class Repositories implements Iterable> {
return null;
});
- Boolean presentAndPrimary = factoryToUse.map(it -> it.getBeanDefinition(name)) //
+ Boolean presentAndPrimary = factoryToUse.map(it -> it.getMergedBeanDefinition(name)) //
.map(BeanDefinition::isPrimary) //
.orElse(false);