Skip to content

Commit a88748d

Browse files
committed
Remove @Persistent from entity-scan include filters.
We now only scan for entities annotated with `@Document` to avoid inclusion of non-MongoDB entities. Previously, types annotated (or meta-annotated) with `@Persistent` were included as MongoDB entity which could lead to mapping rule violations. Closes #3592
1 parent c2fc09e commit a88748d

File tree

1 file changed

+1
-4
lines changed

1 file changed

+1
-4
lines changed

spring-data-mongodb/src/main/java/org/springframework/data/mongodb/config/MongoConfigurationSupport.java

+1-4
Original file line numberDiff line numberDiff line change
@@ -26,7 +26,6 @@
2626
import org.springframework.context.annotation.ClassPathScanningCandidateComponentProvider;
2727
import org.springframework.core.convert.converter.Converter;
2828
import org.springframework.core.type.filter.AnnotationTypeFilter;
29-
import org.springframework.data.annotation.Persistent;
3029
import org.springframework.data.convert.CustomConversions;
3130
import org.springframework.data.mapping.model.CamelCaseAbbreviatingFieldNamingStrategy;
3231
import org.springframework.data.mapping.model.FieldNamingStrategy;
@@ -140,8 +139,7 @@ protected Set<Class<?>> getInitialEntitySet() throws ClassNotFoundException {
140139
}
141140

142141
/**
143-
* Scans the given base package for entities, i.e. MongoDB specific types annotated with {@link Document} and
144-
* {@link Persistent}.
142+
* Scans the given base package for entities, i.e. MongoDB specific types annotated with {@link Document}.
145143
*
146144
* @param basePackage must not be {@literal null}.
147145
* @return
@@ -161,7 +159,6 @@ protected Set<Class<?>> scanForEntities(String basePackage) throws ClassNotFound
161159
ClassPathScanningCandidateComponentProvider componentProvider = new ClassPathScanningCandidateComponentProvider(
162160
false);
163161
componentProvider.addIncludeFilter(new AnnotationTypeFilter(Document.class));
164-
componentProvider.addIncludeFilter(new AnnotationTypeFilter(Persistent.class));
165162

166163
for (BeanDefinition candidate : componentProvider.findCandidateComponents(basePackage)) {
167164

0 commit comments

Comments
 (0)