Skip to content

Commit

Permalink
Remove @Persistent from entity-scan include filters.
Browse files Browse the repository at this point in the history
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
  • Loading branch information
mp911de committed Mar 11, 2021
1 parent c2fc09e commit a88748d
Showing 1 changed file with 1 addition and 4 deletions.
Expand Up @@ -26,7 +26,6 @@
import org.springframework.context.annotation.ClassPathScanningCandidateComponentProvider;
import org.springframework.core.convert.converter.Converter;
import org.springframework.core.type.filter.AnnotationTypeFilter;
import org.springframework.data.annotation.Persistent;
import org.springframework.data.convert.CustomConversions;
import org.springframework.data.mapping.model.CamelCaseAbbreviatingFieldNamingStrategy;
import org.springframework.data.mapping.model.FieldNamingStrategy;
Expand Down Expand Up @@ -140,8 +139,7 @@ protected Set<Class<?>> getInitialEntitySet() throws ClassNotFoundException {
}

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

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

Expand Down

0 comments on commit a88748d

Please sign in to comment.