@@ -539,7 +539,7 @@ private AssociationHandler<Neo4jPersistentProperty> populateFrom(MapAccessor que
539
539
&& propertyValueNotNull ;
540
540
541
541
if (populatedCollection ) {
542
- createInstanceOfRelationships (persistentProperty , queryResult , (RelationshipDescription ) association , baseDescription , relationshipsFromResult , nodesFromResult )
542
+ createInstanceOfRelationships (persistentProperty , queryResult , (RelationshipDescription ) association , baseDescription , relationshipsFromResult , nodesFromResult , false )
543
543
.ifPresent (value -> {
544
544
Collection <?> providedCollection = (Collection <?>) value ;
545
545
Collection <?> existingValue = (Collection <?>) propertyValue ;
@@ -586,9 +586,15 @@ private AssociationHandler<Neo4jPersistentProperty> populateFrom(MapAccessor que
586
586
};
587
587
}
588
588
589
+ private Optional <Object > createInstanceOfRelationships (Neo4jPersistentProperty persistentProperty , MapAccessor values ,
590
+ RelationshipDescription relationshipDescription , NodeDescription <?> baseDescription , Collection <Relationship > relationshipsFromResult ,
591
+ Collection <Node > nodesFromResult ) {
592
+ return createInstanceOfRelationships (persistentProperty , values , relationshipDescription , baseDescription , relationshipsFromResult , nodesFromResult , true );
593
+ }
594
+
589
595
private Optional <Object > createInstanceOfRelationships (Neo4jPersistentProperty persistentProperty , MapAccessor values ,
590
596
RelationshipDescription relationshipDescription , NodeDescription <?> baseDescription , Collection <Relationship > relationshipsFromResult ,
591
- Collection <Node > nodesFromResult ) {
597
+ Collection <Node > nodesFromResult , boolean fetchMore ) {
592
598
593
599
String typeOfRelationship = relationshipDescription .getType ();
594
600
String targetLabel = relationshipDescription .getTarget ().getPrimaryLabel ();
@@ -663,14 +669,16 @@ private Optional<Object> createInstanceOfRelationships(Neo4jPersistentProperty p
663
669
// the property population of _this_ object.
664
670
// The initial population will happen at the end of this mapping. This is sufficient because
665
671
// it only affects properties not changing the instance of the object.
666
- Object mappedObject = sourceNodeId != null && sourceNodeId .equals (targetNodeId )
667
- ? knownObjects .getObject (sourceNodeId )
668
- : map (possibleValueNode , concreteTargetNodeDescription , null , relationshipsFromResult , nodesFromResult );
672
+ Object mappedObject = fetchMore
673
+ ? sourceNodeId != null && sourceNodeId .equals (targetNodeId )
674
+ ? knownObjects .getObject (sourceNodeId )
675
+ : map (possibleValueNode , concreteTargetNodeDescription , null , relationshipsFromResult , nodesFromResult )
676
+ : knownObjects .getObject (targetNodeId );
669
677
if (relationshipDescription .hasRelationshipProperties ()) {
670
678
671
- Object relationshipProperties = map ( possibleRelationship ,
672
- ( Neo4jPersistentEntity <?>) relationshipDescription .getRelationshipPropertiesEntity (),
673
- mappedObject , relationshipsFromResult , nodesFromResult );
679
+ Object relationshipProperties = fetchMore
680
+ ? map ( possibleRelationship , ( Neo4jPersistentEntity <?>) relationshipDescription .getRelationshipPropertiesEntity (), mappedObject , relationshipsFromResult , nodesFromResult )
681
+ : knownObjects . getObject ( getInternalId ( possibleRelationship ) );
674
682
relationshipsAndProperties .add (relationshipProperties );
675
683
mappedObjectHandler .accept (possibleRelationship .type (), relationshipProperties );
676
684
} else {
@@ -687,7 +695,9 @@ private Optional<Object> createInstanceOfRelationships(Neo4jPersistentProperty p
687
695
Neo4jPersistentEntity <?> concreteTargetNodeDescription =
688
696
getMostConcreteTargetNodeDescription (genericTargetNodeDescription , relatedEntity );
689
697
690
- Object valueEntry = map (relatedEntity , concreteTargetNodeDescription , null , relationshipsFromResult , nodesFromResult );
698
+ Object valueEntry = fetchMore
699
+ ? map (relatedEntity , concreteTargetNodeDescription , null , relationshipsFromResult , nodesFromResult )
700
+ : knownObjects .getObject (getInternalId (relatedEntity ));
691
701
692
702
if (relationshipDescription .hasRelationshipProperties ()) {
693
703
String sourceLabel = relationshipDescription .getSource ().getMostAbstractParentLabel (baseDescription );
@@ -696,9 +706,10 @@ private Optional<Object> createInstanceOfRelationships(Neo4jPersistentProperty p
696
706
Relationship relatedEntityRelationship = relatedEntity .get (relationshipSymbolicName )
697
707
.asRelationship ();
698
708
699
- Object relationshipProperties = map (relatedEntityRelationship ,
700
- (Neo4jPersistentEntity <?>) relationshipDescription .getRelationshipPropertiesEntity (),
701
- valueEntry , relationshipsFromResult , nodesFromResult );
709
+ Object relationshipProperties = fetchMore
710
+ ? map (relatedEntityRelationship , (Neo4jPersistentEntity <?>) relationshipDescription .getRelationshipPropertiesEntity (), valueEntry , relationshipsFromResult , nodesFromResult )
711
+ : knownObjects .getObject (getInternalId (relatedEntityRelationship ));
712
+
702
713
relationshipsAndProperties .add (relationshipProperties );
703
714
mappedObjectHandler .accept (relatedEntity .get (RelationshipDescription .NAME_OF_RELATIONSHIP_TYPE ).asString (), relationshipProperties );
704
715
} else {
0 commit comments