Don't scan for `@Persistent` types as they may not be meant for Neo4j

Closes gh-25069
pull/25507/head
Andy Wilkinson 4 years ago
parent 34150d01b7
commit 08e86741fd

@ -1,5 +1,5 @@
/*
* Copyright 2012-2020 the original author or authors.
* Copyright 2012-2021 the original author or authors.
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
@ -35,7 +35,6 @@ import org.springframework.boot.context.properties.EnableConfigurationProperties
import org.springframework.context.ApplicationContext;
import org.springframework.context.annotation.Bean;
import org.springframework.context.annotation.Configuration;
import org.springframework.data.annotation.Persistent;
import org.springframework.data.neo4j.core.DatabaseSelectionProvider;
import org.springframework.data.neo4j.core.Neo4jClient;
import org.springframework.data.neo4j.core.Neo4jOperations;
@ -78,7 +77,7 @@ public class Neo4jDataAutoConfiguration {
@ConditionalOnMissingBean
public Neo4jMappingContext neo4jMappingContext(ApplicationContext applicationContext,
Neo4jConversions neo4jConversions) throws ClassNotFoundException {
Set<Class<?>> initialEntityClasses = new EntityScanner(applicationContext).scan(Node.class, Persistent.class,
Set<Class<?>> initialEntityClasses = new EntityScanner(applicationContext).scan(Node.class,
RelationshipProperties.class);
Neo4jMappingContext context = new Neo4jMappingContext(neo4jConversions);
context.setInitialEntitySet(initialEntityClasses);

@ -1,5 +1,5 @@
/*
* Copyright 2012-2020 the original author or authors.
* Copyright 2012-2021 the original author or authors.
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
@ -148,7 +148,7 @@ class Neo4jDataAutoConfigurationTests {
this.contextRunner.withUserConfiguration(EntityScanConfig.class).run((context) -> {
Neo4jMappingContext mappingContext = context.getBean(Neo4jMappingContext.class);
assertThat(mappingContext.hasPersistentEntityFor(TestNode.class)).isTrue();
assertThat(mappingContext.hasPersistentEntityFor(TestPersistent.class)).isTrue();
assertThat(mappingContext.hasPersistentEntityFor(TestPersistent.class)).isFalse();
assertThat(mappingContext.hasPersistentEntityFor(TestRelationshipProperties.class)).isTrue();
assertThat(mappingContext.hasPersistentEntityFor(TestNonAnnotated.class)).isFalse();
});

@ -1,5 +1,5 @@
/*
* Copyright 2012-2020 the original author or authors.
* Copyright 2012-2021 the original author or authors.
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
@ -132,7 +132,7 @@ class Neo4jReactiveDataAutoConfigurationTests {
this.contextRunner.withUserConfiguration(EntityScanConfig.class).run((context) -> {
Neo4jMappingContext mappingContext = context.getBean(Neo4jMappingContext.class);
assertThat(mappingContext.hasPersistentEntityFor(TestNode.class)).isTrue();
assertThat(mappingContext.hasPersistentEntityFor(TestPersistent.class)).isTrue();
assertThat(mappingContext.hasPersistentEntityFor(TestPersistent.class)).isFalse();
assertThat(mappingContext.hasPersistentEntityFor(TestRelationshipProperties.class)).isTrue();
assertThat(mappingContext.hasPersistentEntityFor(TestNonAnnotated.class)).isFalse();
});

Loading…
Cancel
Save