@@ -468,8 +468,8 @@ private <T> T saveImpl(T instance, @Nullable Collection<PropertyFilter.Projected
468468 TemplateSupport .FilteredBinderFunction <T > binderFunction = TemplateSupport .createAndApplyPropertyFilter (
469469 includedProperties , entityMetaData ,
470470 this .neo4jMappingContext .getRequiredBinderFunctionFor ((Class <T >) entityToBeSaved .getClass ()));
471- var statement = this . cypherGenerator . prepareSaveOf ( entityMetaData , dynamicLabels ,
472- TemplateSupport . rendererRendersElementId ( this .renderer ) );
471+ var canUseElementId = TemplateSupport . rendererRendersElementId ( this . renderer );
472+ var statement = this .cypherGenerator . prepareSaveOf ( entityMetaData , dynamicLabels , canUseElementId );
473473 Optional <Entity > newOrUpdatedNode = this .neo4jClient .query (() -> this .renderer .render (statement ))
474474 .bind (entityToBeSaved )
475475 .with (binderFunction )
@@ -486,8 +486,7 @@ private <T> T saveImpl(T instance, @Nullable Collection<PropertyFilter.Projected
486486 }
487487
488488 Object elementId = newOrUpdatedNode .map (node -> {
489- if (!entityMetaData .isUsingDeprecatedInternalId ()
490- && TemplateSupport .rendererRendersElementId (this .renderer )) {
489+ if (!entityMetaData .isUsingDeprecatedInternalId () && canUseElementId ) {
491490 return IdentitySupport .getElementId (node );
492491 }
493492 @ SuppressWarnings ("deprecation" )
@@ -504,7 +503,8 @@ private <T> T saveImpl(T instance, @Nullable Collection<PropertyFilter.Projected
504503 }
505504
506505 stateMachine .markEntityAsProcessed (instance , elementId );
507- processRelations (entityMetaData , propertyAccessor , isEntityNew , stateMachine , binderFunction .filter );
506+ processRelations (entityMetaData , propertyAccessor , isEntityNew , stateMachine , binderFunction .filter ,
507+ canUseElementId );
508508
509509 T bean = propertyAccessor .getBean ();
510510 stateMachine .markAsAliased (instance , bean );
@@ -648,7 +648,8 @@ class Tuple3<T> {
648648 TemplateSupport .computeIncludePropertyPredicate (
649649 ((includedProperties != null && !includedProperties .isEmpty ()) || includeProperty != null )
650650 ? pps : includedPropertiesByClass .get (t .modifiedInstance .getClass ()),
651- entityMetaData ));
651+ entityMetaData ),
652+ TemplateSupport .rendererRendersElementId (this .renderer ));
652653 }).collect (Collectors .toList ());
653654 }
654655
@@ -856,24 +857,26 @@ private <T> ExecutableQuery<T> createExecutableQuery(Class<T> domainType, @Nulla
856857 * @param stateMachine initial state of entity processing
857858 * @param includeProperty a predicate telling to include a relationship property or
858859 * not
860+ * @param canUseElementId flag if the Cypher DSL renderer supports elementId function
859861 * @param <T> the type of the object being initially processed
860862 * @return the owner of the relations being processed
861863 */
862864 private <T > T processRelations (Neo4jPersistentEntity <?> neo4jPersistentEntity ,
863865 PersistentPropertyAccessor <?> parentPropertyAccessor , boolean isParentObjectNew ,
864- NestedRelationshipProcessingStateMachine stateMachine , PropertyFilter includeProperty ) {
866+ NestedRelationshipProcessingStateMachine stateMachine , PropertyFilter includeProperty ,
867+ boolean canUseElementId ) {
865868
866869 PropertyFilter .RelaxedPropertyPath startingPropertyPath = PropertyFilter .RelaxedPropertyPath
867870 .withRootType (neo4jPersistentEntity .getUnderlyingClass ());
868871 return processNestedRelations (neo4jPersistentEntity , parentPropertyAccessor , isParentObjectNew , stateMachine ,
869- includeProperty , startingPropertyPath );
872+ includeProperty , canUseElementId , startingPropertyPath );
870873 }
871874
872875 @ SuppressWarnings ("deprecation" )
873876 private <T > T processNestedRelations (Neo4jPersistentEntity <?> sourceEntity ,
874877 PersistentPropertyAccessor <?> propertyAccessor , boolean isParentObjectNew ,
875878 NestedRelationshipProcessingStateMachine stateMachine , PropertyFilter includeProperty ,
876- PropertyFilter .RelaxedPropertyPath previousPath ) {
879+ boolean canUseElementId , PropertyFilter .RelaxedPropertyPath previousPath ) {
877880
878881 Object fromId = propertyAccessor .getProperty (sourceEntity .getRequiredIdProperty ());
879882
@@ -921,7 +924,6 @@ private <T> T processNestedRelations(Neo4jPersistentEntity<?> sourceEntity,
921924 // has not been processed before.
922925 // This avoids the usage of cache but might have significant impact on overall
923926 // performance
924- boolean canUseElementId = TemplateSupport .rendererRendersElementId (this .renderer );
925927 if (!isParentObjectNew && !stateMachine .hasProcessedRelationship (fromId , relationshipDescription )) {
926928
927929 List <Object > knownRelationshipsIds = new ArrayList <>();
@@ -1121,7 +1123,7 @@ else if (relationshipDescription.hasRelationshipProperties() && fromId != null)
11211123
11221124 if (processState != ProcessState .PROCESSED_ALL_VALUES ) {
11231125 processNestedRelations (targetEntity , targetPropertyAccessor , isNewEntity , stateMachine ,
1124- includeProperty , currentPropertyPath );
1126+ includeProperty , canUseElementId , currentPropertyPath );
11251127 }
11261128
11271129 Object potentiallyRecreatedNewRelatedObject = MappingSupport
0 commit comments