Skip to content

Commit

Permalink
refactor: Extract requiresSingleStatements for better readability.
Browse files Browse the repository at this point in the history
Co-authored-by: Michael Simons <[email protected]>
  • Loading branch information
akshatbiztech and michael-simons authored Nov 27, 2023
1 parent 52f6714 commit 4eb08ab
Showing 1 changed file with 9 additions and 2 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -467,6 +467,13 @@ public <T> List<T> saveAll(Iterable<T> instances) {
return saveAllImpl(instances, Collections.emptySet(), null);
}

private boolean requiresSingleStatements(boolean heterogeneousCollection, Neo4jPersistentEntity<?> entityMetaData) {
return heterogeneousCollection
|| entityMetaData.isUsingInternalIds()
|| entityMetaData.hasVersionProperty()
|| entityMetaData.getDynamicLabelsProperty().isPresent();
}

private <T> List<T> saveAllImpl(Iterable<T> instances, @Nullable Collection<PropertyFilter.ProjectedPath> includedProperties, @Nullable BiPredicate<PropertyPath, Neo4jPersistentProperty> includeProperty) {

Set<Class<?>> types = new HashSet<>();
Expand All @@ -489,8 +496,8 @@ private <T> List<T> saveAllImpl(Iterable<T> instances, @Nullable Collection<Prop
includeProperty);

Neo4jPersistentEntity<?> entityMetaData = neo4jMappingContext.getRequiredPersistentEntity(domainClass);
if (heterogeneousCollection || entityMetaData.isUsingInternalIds() || entityMetaData.hasVersionProperty()
|| entityMetaData.getDynamicLabelsProperty().isPresent()) {

if (requiresSingleStatements(heterogeneousCollection, entityMetaData)) {
log.debug("Saving entities using single statements.");

NestedRelationshipProcessingStateMachine stateMachine = new NestedRelationshipProcessingStateMachine(neo4jMappingContext);
Expand Down

0 comments on commit 4eb08ab

Please sign in to comment.