Skip to content

Commit

Permalink
Use Neo4jManagedTypes to populate the mapping context.
Browse files Browse the repository at this point in the history
  • Loading branch information
michael-simons committed Sep 27, 2023
1 parent 32c91af commit f9222d3
Showing 1 changed file with 10 additions and 3 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -33,6 +33,7 @@
import org.springframework.boot.context.properties.EnableConfigurationProperties;
import org.springframework.context.ApplicationContext;
import org.springframework.context.annotation.Bean;
import org.springframework.data.neo4j.aot.Neo4jManagedTypes;
import org.springframework.data.neo4j.core.DatabaseSelectionProvider;
import org.springframework.data.neo4j.core.Neo4jClient;
import org.springframework.data.neo4j.core.Neo4jOperations;
Expand Down Expand Up @@ -71,12 +72,18 @@ public Neo4jConversions neo4jConversions() {

@Bean
@ConditionalOnMissingBean
public Neo4jMappingContext neo4jMappingContext(ApplicationContext applicationContext,
Neo4jConversions neo4jConversions) throws ClassNotFoundException {
Neo4jManagedTypes neo4jManagedTypes(ApplicationContext applicationContext) throws ClassNotFoundException {
Set<Class<?>> initialEntityClasses = new EntityScanner(applicationContext).scan(Node.class,
RelationshipProperties.class);
return Neo4jManagedTypes.fromIterable(initialEntityClasses);
}

@Bean
@ConditionalOnMissingBean
public Neo4jMappingContext neo4jMappingContext(Neo4jManagedTypes managedTypes, Neo4jConversions neo4jConversions) {

Neo4jMappingContext context = new Neo4jMappingContext(neo4jConversions);
context.setInitialEntitySet(initialEntityClasses);
context.setManagedTypes(managedTypes);
return context;
}

Expand Down

0 comments on commit f9222d3

Please sign in to comment.