From 4eb08abadea27dcb30ddbf8fedc84dc7645e27d7 Mon Sep 17 00:00:00 2001 From: Akshat Shah Date: Mon, 27 Nov 2023 06:52:53 -0400 Subject: [PATCH] refactor: Extract `requiresSingleStatements` for better readability. Co-authored-by: Michael Simons --- .../data/neo4j/core/Neo4jTemplate.java | 11 +++++++++-- 1 file changed, 9 insertions(+), 2 deletions(-) diff --git a/src/main/java/org/springframework/data/neo4j/core/Neo4jTemplate.java b/src/main/java/org/springframework/data/neo4j/core/Neo4jTemplate.java index 89dff6c83..f55a4bc90 100644 --- a/src/main/java/org/springframework/data/neo4j/core/Neo4jTemplate.java +++ b/src/main/java/org/springframework/data/neo4j/core/Neo4jTemplate.java @@ -467,6 +467,13 @@ public List saveAll(Iterable instances) { return saveAllImpl(instances, Collections.emptySet(), null); } + private boolean requiresSingleStatements(boolean heterogeneousCollection, Neo4jPersistentEntity entityMetaData) { + return heterogeneousCollection + || entityMetaData.isUsingInternalIds() + || entityMetaData.hasVersionProperty() + || entityMetaData.getDynamicLabelsProperty().isPresent(); + } + private List saveAllImpl(Iterable instances, @Nullable Collection includedProperties, @Nullable BiPredicate includeProperty) { Set> types = new HashSet<>(); @@ -489,8 +496,8 @@ private List saveAllImpl(Iterable instances, @Nullable Collection 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);