@@ -299,10 +299,10 @@ private static MapAccessor mergeRootNodeWithRecord(Node node, MapAccessor record
299
299
private <ET > ET map (MapAccessor queryResult , MapAccessor allValues , Neo4jPersistentEntity <ET > nodeDescription ) {
300
300
Collection <Relationship > relationshipsFromResult = extractRelationships (allValues );
301
301
Collection <Node > nodesFromResult = extractNodes (allValues );
302
- return map (queryResult , nodeDescription , null , null , relationshipsFromResult , nodesFromResult );
302
+ return map (queryResult , nodeDescription , nodeDescription , null , null , relationshipsFromResult , nodesFromResult );
303
303
}
304
304
305
- private <ET > ET map (MapAccessor queryResult , Neo4jPersistentEntity <ET > nodeDescription ,
305
+ private <ET > ET map (MapAccessor queryResult , Neo4jPersistentEntity <ET > nodeDescription , NodeDescription <?> genericTargetNodeDescription ,
306
306
@ Nullable Object lastMappedEntity , @ Nullable RelationshipDescription relationshipDescription , Collection <Relationship > relationshipsFromResult , Collection <Node > nodesFromResult ) {
307
307
308
308
// if the given result does not contain an identifier to the mapped object cannot get temporarily saved
@@ -327,7 +327,7 @@ private <ET> ET map(MapAccessor queryResult, Neo4jPersistentEntity<ET> nodeDescr
327
327
Neo4jPersistentEntity <ET > concreteNodeDescription = (Neo4jPersistentEntity <ET >) nodeDescriptionAndLabels
328
328
.getNodeDescription ();
329
329
330
- ET instance = instantiate (concreteNodeDescription , queryResult ,
330
+ ET instance = instantiate (concreteNodeDescription , genericTargetNodeDescription , queryResult ,
331
331
nodeDescriptionAndLabels .getDynamicLabels (), lastMappedEntity , relationshipsFromResult , nodesFromResult );
332
332
333
333
knownObjects .removeFromInCreation (internalId );
@@ -475,7 +475,7 @@ private boolean containsOnePlainNode(MapAccessor queryResult) {
475
475
.filter (value -> value .hasType (nodeType )).count () == 1L ;
476
476
}
477
477
478
- private <ET > ET instantiate (Neo4jPersistentEntity <ET > nodeDescription , MapAccessor values ,
478
+ private <ET > ET instantiate (Neo4jPersistentEntity <ET > nodeDescription , NodeDescription <?> genericNodeDescription , MapAccessor values ,
479
479
Collection <String > surplusLabels , @ Nullable Object lastMappedEntity ,
480
480
Collection <Relationship > relationshipsFromResult , Collection <Node > nodesFromResult ) {
481
481
@@ -496,12 +496,12 @@ public <T> T getParameterValue(Parameter<T, Neo4jPersistentProperty> parameter)
496
496
// If we cannot find any value it does not mean that there isn't any.
497
497
// The result set might contain associations not named CONCRETE_TYPE_TARGET but ABSTRACT_TYPE_TARGET.
498
498
// For this we bubble up the hierarchy of NodeDescriptions.
499
- result = createInstanceOfRelationships (matchingProperty , values , relationshipDescription , nodeDescription , relationshipsFromResult , nodesFromResult )
499
+ result = createInstanceOfRelationships (matchingProperty , values , relationshipDescription , nodeDescription , genericNodeDescription , relationshipsFromResult , nodesFromResult )
500
500
.orElseGet (() -> {
501
501
NodeDescription <?> parentNodeDescription = nodeDescription .getParentNodeDescription ();
502
502
T resultValue = null ;
503
503
while (parentNodeDescription != null ) {
504
- Optional <Object > value = createInstanceOfRelationships (matchingProperty , values , relationshipDescription , parentNodeDescription , relationshipsFromResult , nodesFromResult );
504
+ Optional <Object > value = createInstanceOfRelationships (matchingProperty , values , relationshipDescription , parentNodeDescription , parentNodeDescription , relationshipsFromResult , nodesFromResult );
505
505
if (value .isPresent ()) {
506
506
resultValue = (T ) value .get ();
507
507
break ;
@@ -594,7 +594,7 @@ private AssociationHandler<Neo4jPersistentProperty> populateFrom(MapAccessor que
594
594
&& propertyValueNotNull ;
595
595
596
596
if (populatedCollection ) {
597
- createInstanceOfRelationships (persistentProperty , queryResult , (RelationshipDescription ) association , baseDescription , relationshipsFromResult , nodesFromResult , false )
597
+ createInstanceOfRelationships (persistentProperty , queryResult , (RelationshipDescription ) association , baseDescription , baseDescription , relationshipsFromResult , nodesFromResult , false )
598
598
.ifPresent (value -> {
599
599
Collection <?> providedCollection = (Collection <?>) value ;
600
600
Collection <?> existingValue = (Collection <?>) propertyValue ;
@@ -617,7 +617,7 @@ private AssociationHandler<Neo4jPersistentProperty> populateFrom(MapAccessor que
617
617
return ;
618
618
}
619
619
620
- createInstanceOfRelationships (persistentProperty , queryResult , (RelationshipDescription ) association , baseDescription , relationshipsFromResult , nodesFromResult )
620
+ createInstanceOfRelationships (persistentProperty , queryResult , (RelationshipDescription ) association , baseDescription , baseDescription , relationshipsFromResult , nodesFromResult )
621
621
.ifPresent (value -> propertyAccessor .setProperty (persistentProperty , value ));
622
622
};
623
623
}
@@ -641,13 +641,13 @@ private void mergeCollections(RelationshipDescription relationshipDescription, C
641
641
}
642
642
643
643
private Optional <Object > createInstanceOfRelationships (Neo4jPersistentProperty persistentProperty , MapAccessor values ,
644
- RelationshipDescription relationshipDescription , NodeDescription <?> baseDescription , Collection <Relationship > relationshipsFromResult ,
644
+ RelationshipDescription relationshipDescription , NodeDescription <?> baseDescription , NodeDescription <?> genericNodeDescription , Collection <Relationship > relationshipsFromResult ,
645
645
Collection <Node > nodesFromResult ) {
646
- return createInstanceOfRelationships (persistentProperty , values , relationshipDescription , baseDescription , relationshipsFromResult , nodesFromResult , true );
646
+ return createInstanceOfRelationships (persistentProperty , values , relationshipDescription , baseDescription , genericNodeDescription , relationshipsFromResult , nodesFromResult , true );
647
647
}
648
648
649
649
private Optional <Object > createInstanceOfRelationships (Neo4jPersistentProperty persistentProperty , MapAccessor values ,
650
- RelationshipDescription relationshipDescription , NodeDescription <?> baseDescription , Collection <Relationship > relationshipsFromResult ,
650
+ RelationshipDescription relationshipDescription , NodeDescription <?> baseDescription , NodeDescription <?> genericNodeDescription , Collection <Relationship > relationshipsFromResult ,
651
651
Collection <Node > nodesFromResult , boolean fetchMore ) {
652
652
653
653
String typeOfRelationship = relationshipDescription .getType ();
@@ -681,7 +681,7 @@ private Optional<Object> createInstanceOfRelationships(Neo4jPersistentProperty p
681
681
mappedObjectHandler = (type , mappedObject ) -> value .add (mappedObject );
682
682
}
683
683
684
- String collectionName = relationshipDescription .generateRelatedNodesCollectionName (baseDescription );
684
+ String collectionName = relationshipDescription .generateRelatedNodesCollectionName (genericNodeDescription );
685
685
686
686
Value list = values .get (collectionName );
687
687
@@ -728,23 +728,24 @@ private Optional<Object> createInstanceOfRelationships(Neo4jPersistentProperty p
728
728
if (fetchMore ) {
729
729
mappedObject = sourceNodeId != null && sourceNodeId .equals (targetNodeId )
730
730
? knownObjects .getObject ("N" + sourceNodeId )
731
- : map (possibleValueNode , concreteTargetNodeDescription , null , null , relationshipsFromResult , nodesFromResult );
731
+ : map (possibleValueNode , concreteTargetNodeDescription , genericNodeDescription , null , null , relationshipsFromResult , nodesFromResult );
732
732
} else {
733
733
Object objectFromStore = knownObjects .getObject ("N" + targetNodeId );
734
734
mappedObject = objectFromStore != null
735
735
? objectFromStore
736
- : map (possibleValueNode , concreteTargetNodeDescription , null , null , relationshipsFromResult , nodesFromResult );
736
+ : map (possibleValueNode , concreteTargetNodeDescription , genericNodeDescription , null , null , relationshipsFromResult , nodesFromResult );
737
737
}
738
738
739
739
if (relationshipDescription .hasRelationshipProperties ()) {
740
740
Object relationshipProperties ;
741
+ Neo4jPersistentEntity <?> relationshipPropertiesEntity = (Neo4jPersistentEntity <?>) relationshipDescription .getRelationshipPropertiesEntity ();
741
742
if (fetchMore ) {
742
- relationshipProperties = map (possibleRelationship , ( Neo4jPersistentEntity <?>) relationshipDescription . getRelationshipPropertiesEntity () , mappedObject , relationshipDescription , relationshipsFromResult , nodesFromResult );
743
+ relationshipProperties = map (possibleRelationship , relationshipPropertiesEntity , relationshipPropertiesEntity , mappedObject , relationshipDescription , relationshipsFromResult , nodesFromResult );
743
744
} else {
744
745
Object objectFromStore = knownObjects .getObject (getInternalId (possibleRelationship , relationshipDescription .getDirection ().name ()));
745
746
relationshipProperties = objectFromStore != null
746
747
? objectFromStore
747
- : map (possibleRelationship , ( Neo4jPersistentEntity <?>) relationshipDescription . getRelationshipPropertiesEntity () , mappedObject , relationshipDescription , relationshipsFromResult , nodesFromResult );
748
+ : map (possibleRelationship , relationshipPropertiesEntity , relationshipPropertiesEntity , mappedObject , relationshipDescription , relationshipsFromResult , nodesFromResult );
748
749
}
749
750
relationshipsAndProperties .add (relationshipProperties );
750
751
mappedObjectHandler .accept (possibleRelationship .type (), relationshipProperties );
@@ -764,29 +765,30 @@ private Optional<Object> createInstanceOfRelationships(Neo4jPersistentProperty p
764
765
765
766
Object valueEntry ;
766
767
if (fetchMore ) {
767
- valueEntry = map (relatedEntity , concreteTargetNodeDescription , null , null , relationshipsFromResult , nodesFromResult );
768
+ valueEntry = map (relatedEntity , concreteTargetNodeDescription , genericNodeDescription , null , null , relationshipsFromResult , nodesFromResult );
768
769
} else {
769
770
Object objectFromStore = knownObjects .getObject (getInternalId (relatedEntity , null ));
770
771
valueEntry = objectFromStore != null
771
772
? objectFromStore
772
- : map (relatedEntity , concreteTargetNodeDescription , null , null , relationshipsFromResult , nodesFromResult );
773
+ : map (relatedEntity , concreteTargetNodeDescription , genericNodeDescription , null , null , relationshipsFromResult , nodesFromResult );
773
774
}
774
775
775
776
if (relationshipDescription .hasRelationshipProperties ()) {
776
- String sourceLabel = relationshipDescription .getSource ().getMostAbstractParentLabel (baseDescription );
777
+ String sourceLabel = relationshipDescription .getSource ().getMostAbstractParentLabel (genericNodeDescription );
777
778
String relationshipSymbolicName = sourceLabel
778
779
+ RelationshipDescription .NAME_OF_RELATIONSHIP + targetLabel ;
779
780
Relationship relatedEntityRelationship = relatedEntity .get (relationshipSymbolicName )
780
781
.asRelationship ();
781
782
782
783
Object relationshipProperties ;
784
+ Neo4jPersistentEntity <?> relationshipPropertiesEntity = (Neo4jPersistentEntity <?>) relationshipDescription .getRelationshipPropertiesEntity ();
783
785
if (fetchMore ) {
784
- relationshipProperties = map (relatedEntityRelationship , ( Neo4jPersistentEntity <?>) relationshipDescription . getRelationshipPropertiesEntity () , valueEntry , relationshipDescription , relationshipsFromResult , nodesFromResult );
786
+ relationshipProperties = map (relatedEntityRelationship , relationshipPropertiesEntity , relationshipPropertiesEntity , valueEntry , relationshipDescription , relationshipsFromResult , nodesFromResult );
785
787
} else {
786
788
Object objectFromStore = knownObjects .getObject (getInternalId (relatedEntityRelationship , relationshipDescription .getDirection ().name ()));
787
789
relationshipProperties = objectFromStore != null
788
790
? objectFromStore
789
- : map (relatedEntityRelationship , ( Neo4jPersistentEntity <?>) relationshipDescription . getRelationshipPropertiesEntity () , valueEntry , relationshipDescription , relationshipsFromResult , nodesFromResult );
791
+ : map (relatedEntityRelationship , relationshipPropertiesEntity , relationshipPropertiesEntity , valueEntry , relationshipDescription , relationshipsFromResult , nodesFromResult );
790
792
}
791
793
792
794
relationshipsAndProperties .add (relationshipProperties );
0 commit comments