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 23
23
import java .util .List ;
24
24
import java .util .Map ;
25
25
import java .util .Optional ;
26
+ import java .util .Set ;
26
27
import java .util .concurrent .locks .Lock ;
27
28
import java .util .concurrent .locks .ReentrantReadWriteLock ;
28
29
import java .util .function .BiConsumer ;
@@ -482,7 +483,7 @@ private Optional<Object> createInstanceOfRelationships(Neo4jPersistentProperty p
482
483
Long sourceNodeId = getInternalId (values );
483
484
for (Node possibleValueNode : allNodesWithMatchingLabelInResult ) {
484
485
long targetNodeId = possibleValueNode .id ();
485
-
486
+ Set < Relationship > relationshipsProcessed = new HashSet <>();
486
487
for (Relationship possibleRelationship : allMatchingTypeRelationshipsInResult ) {
487
488
if (targetIdSelector .apply (possibleRelationship ) == targetNodeId && sourceIdSelector .apply (possibleRelationship ).equals (sourceNodeId )) {
488
489
@@ -500,10 +501,10 @@ private Optional<Object> createInstanceOfRelationships(Neo4jPersistentProperty p
500
501
} else {
501
502
mappedObjectHandler .accept (possibleRelationship .type (), mappedObject );
502
503
}
503
- allMatchingTypeRelationshipsInResult .remove (possibleRelationship );
504
- break ;
504
+ relationshipsProcessed .add (possibleRelationship );
505
505
}
506
506
}
507
+ allMatchingTypeRelationshipsInResult .removeAll (relationshipsProcessed );
507
508
}
508
509
} else {
509
510
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
1581
1581
rel2 .setAltPerson (altPerson );
1582
1582
1583
1583
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 );
1584
1592
}
1585
1593
1586
1594
@ Test // DATAGRAPH-1434
Original file line number Diff line number Diff line change @@ -35,6 +35,12 @@ public class AltHobby {
35
35
@ Relationship (type = "LIKES" , direction = Relationship .Direction .INCOMING )
36
36
private List <AltLikedByPersonRelationship > likedBy = new ArrayList <>();
37
37
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
+ }
38
44
public Long getId () {
39
45
return id ;
40
46
}
You can’t perform that action at this time.
0 commit comments