Skip to content

Commit 4eb08ab

Browse files
refactor: Extract requiresSingleStatements for better readability.
Co-authored-by: Michael Simons <[email protected]>
1 parent 52f6714 commit 4eb08ab

File tree

1 file changed

+9
-2
lines changed

1 file changed

+9
-2
lines changed

src/main/java/org/springframework/data/neo4j/core/Neo4jTemplate.java

Lines changed: 9 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -467,6 +467,13 @@ public <T> List<T> saveAll(Iterable<T> instances) {
467467
return saveAllImpl(instances, Collections.emptySet(), null);
468468
}
469469

470+
private boolean requiresSingleStatements(boolean heterogeneousCollection, Neo4jPersistentEntity<?> entityMetaData) {
471+
return heterogeneousCollection
472+
|| entityMetaData.isUsingInternalIds()
473+
|| entityMetaData.hasVersionProperty()
474+
|| entityMetaData.getDynamicLabelsProperty().isPresent();
475+
}
476+
470477
private <T> List<T> saveAllImpl(Iterable<T> instances, @Nullable Collection<PropertyFilter.ProjectedPath> includedProperties, @Nullable BiPredicate<PropertyPath, Neo4jPersistentProperty> includeProperty) {
471478

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

491498
Neo4jPersistentEntity<?> entityMetaData = neo4jMappingContext.getRequiredPersistentEntity(domainClass);
492-
if (heterogeneousCollection || entityMetaData.isUsingInternalIds() || entityMetaData.hasVersionProperty()
493-
|| entityMetaData.getDynamicLabelsProperty().isPresent()) {
499+
500+
if (requiresSingleStatements(heterogeneousCollection, entityMetaData)) {
494501
log.debug("Saving entities using single statements.");
495502

496503
NestedRelationshipProcessingStateMachine stateMachine = new NestedRelationshipProcessingStateMachine(neo4jMappingContext);

0 commit comments

Comments
 (0)