File tree Expand file tree Collapse file tree 3 files changed +18
-3
lines changed
main/java/org/springframework/data/neo4j/core/mapping
test/java/org/springframework/data/neo4j/integration Expand file tree Collapse file tree 3 files changed +18
-3
lines changed Original file line number Diff line number Diff line change 2323import java .util .List ;
2424import java .util .Map ;
2525import java .util .Optional ;
26+ import java .util .Set ;
2627import java .util .concurrent .locks .Lock ;
2728import java .util .concurrent .locks .ReentrantReadWriteLock ;
2829import java .util .function .BiConsumer ;
@@ -482,7 +483,7 @@ private Optional<Object> createInstanceOfRelationships(Neo4jPersistentProperty p
482483 Long sourceNodeId = getInternalId (values );
483484 for (Node possibleValueNode : allNodesWithMatchingLabelInResult ) {
484485 long targetNodeId = possibleValueNode .id ();
485-
486+ Set < Relationship > relationshipsProcessed = new HashSet <>();
486487 for (Relationship possibleRelationship : allMatchingTypeRelationshipsInResult ) {
487488 if (targetIdSelector .apply (possibleRelationship ) == targetNodeId && sourceIdSelector .apply (possibleRelationship ).equals (sourceNodeId )) {
488489
@@ -500,10 +501,10 @@ private Optional<Object> createInstanceOfRelationships(Neo4jPersistentProperty p
500501 } else {
501502 mappedObjectHandler .accept (possibleRelationship .type (), mappedObject );
502503 }
503- allMatchingTypeRelationshipsInResult .remove (possibleRelationship );
504- break ;
504+ relationshipsProcessed .add (possibleRelationship );
505505 }
506506 }
507+ allMatchingTypeRelationshipsInResult .removeAll (relationshipsProcessed );
507508 }
508509 } else {
509510 for (Value relatedEntity : list .asList (Function .identity ())) {
Original file line number Diff line number Diff line change @@ -1581,6 +1581,14 @@ void loadSameNodeWithDoubleRelationship(@Autowired HobbyWithRelationshipWithProp
15811581 rel2 .setAltPerson (altPerson );
15821582
15831583 assertThat (likedBy ).containsExactlyInAnyOrder (rel1 , rel2 );
1584+
1585+ Optional <AltHobby > optHobby = repository .findById (hobby .getId ());
1586+ assertThat (optHobby .isPresent ()).isTrue ();
1587+ hobby = optHobby .get ();
1588+ assertThat (hobby .getName ()).isEqualTo ("Music" );
1589+ likedBy = hobby .getLikedBy ();
1590+ assertThat (likedBy ).hasSize (2 );
1591+ assertThat (likedBy ).containsExactlyInAnyOrder (rel1 , rel2 );
15841592 }
15851593
15861594 @ Test // DATAGRAPH-1434
Original file line number Diff line number Diff line change @@ -35,6 +35,12 @@ public class AltHobby {
3535 @ Relationship (type = "LIKES" , direction = Relationship .Direction .INCOMING )
3636 private List <AltLikedByPersonRelationship > likedBy = new ArrayList <>();
3737
38+ @ Relationship (type = "CHILD" , direction = Relationship .Direction .INCOMING )
39+ private List <AltHobby > memberOf = new ArrayList <>();
40+
41+ public List <AltHobby > getMemberOf () {
42+ return memberOf ;
43+ }
3844 public Long getId () {
3945 return id ;
4046 }
You can’t perform that action at this time.
0 commit comments