@@ -327,7 +327,7 @@ private <ET> ET map(MapAccessor queryResult, Neo4jPersistentEntity<ET> nodeDescr
327
327
328
328
knownObjects .removeFromInCreation (internalId );
329
329
330
- populateProperties (queryResult , nodeDescription , internalId , instance , lastMappedEntity , relationshipsFromResult , nodesFromResult , false );
330
+ populateProperties (queryResult , ( Neo4jPersistentEntity < ET >) genericTargetNodeDescription , nodeDescription , internalId , instance , lastMappedEntity , relationshipsFromResult , nodesFromResult , false );
331
331
332
332
PersistentPropertyAccessor <ET > propertyAccessor = concreteNodeDescription .getPropertyAccessor (instance );
333
333
ET bean = propertyAccessor .getBean ();
@@ -352,19 +352,19 @@ private <ET> ET map(MapAccessor queryResult, Neo4jPersistentEntity<ET> nodeDescr
352
352
// AND (!!!)
353
353
// 2. mutable target types
354
354
// because we cannot just create new instances
355
- populateProperties (queryResult , nodeDescription , internalId , mappedObject , lastMappedEntity , relationshipsFromResult , nodesFromResult , true );
355
+ populateProperties (queryResult , ( Neo4jPersistentEntity < ET >) genericTargetNodeDescription , nodeDescription , internalId , mappedObject , lastMappedEntity , relationshipsFromResult , nodesFromResult , true );
356
356
}
357
357
return mappedObject ;
358
358
}
359
359
360
360
361
- private <ET > void populateProperties (MapAccessor queryResult , Neo4jPersistentEntity <ET > nodeDescription , String internalId ,
361
+ private <ET > void populateProperties (MapAccessor queryResult , Neo4jPersistentEntity <ET > baseNodeDescription , Neo4jPersistentEntity < ET > moreConcreteNodeDescription , String internalId ,
362
362
ET mappedObject , @ Nullable Object lastMappedEntity ,
363
363
Collection <Relationship > relationshipsFromResult , Collection <Node > nodesFromResult , boolean objectAlreadyMapped ) {
364
364
365
- List <String > allLabels = getLabels (queryResult , nodeDescription );
365
+ List <String > allLabels = getLabels (queryResult , moreConcreteNodeDescription );
366
366
NodeDescriptionAndLabels nodeDescriptionAndLabels = nodeDescriptionStore
367
- .deriveConcreteNodeDescription (nodeDescription , allLabels );
367
+ .deriveConcreteNodeDescription (moreConcreteNodeDescription , allLabels );
368
368
369
369
@ SuppressWarnings ("unchecked" )
370
370
Neo4jPersistentEntity <ET > concreteNodeDescription = (Neo4jPersistentEntity <ET >) nodeDescriptionAndLabels
@@ -392,7 +392,7 @@ private <ET> void populateProperties(MapAccessor queryResult, Neo4jPersistentEnt
392
392
knownObjects .storeObject (internalId , mappedObject );
393
393
394
394
AssociationHandlerSupport .of (concreteNodeDescription ).doWithAssociations (
395
- populateFrom (queryResult , nodeDescription , propertyAccessor , isConstructorParameter , objectAlreadyMapped , relationshipsFromResult , nodesFromResult ));
395
+ populateFrom (queryResult , baseNodeDescription , propertyAccessor , isConstructorParameter , objectAlreadyMapped , relationshipsFromResult , nodesFromResult ));
396
396
}
397
397
398
398
@ NonNull
@@ -464,12 +464,12 @@ public <T> T getParameterValue(Parameter<T, Neo4jPersistentProperty> parameter)
464
464
// If we cannot find any value it does not mean that there isn't any.
465
465
// The result set might contain associations not named CONCRETE_TYPE_TARGET but ABSTRACT_TYPE_TARGET.
466
466
// For this we bubble up the hierarchy of NodeDescriptions.
467
- result = createInstanceOfRelationships (matchingProperty , values , relationshipDescription , nodeDescription , genericNodeDescription , relationshipsFromResult , nodesFromResult )
467
+ result = createInstanceOfRelationships (matchingProperty , values , relationshipDescription , genericNodeDescription , relationshipsFromResult , nodesFromResult )
468
468
.orElseGet (() -> {
469
469
NodeDescription <?> parentNodeDescription = nodeDescription .getParentNodeDescription ();
470
470
T resultValue = null ;
471
471
while (parentNodeDescription != null ) {
472
- Optional <Object > value = createInstanceOfRelationships (matchingProperty , values , relationshipDescription , parentNodeDescription , parentNodeDescription , relationshipsFromResult , nodesFromResult );
472
+ Optional <Object > value = createInstanceOfRelationships (matchingProperty , values , relationshipDescription , parentNodeDescription , relationshipsFromResult , nodesFromResult );
473
473
if (value .isPresent ()) {
474
474
resultValue = (T ) value .get ();
475
475
break ;
@@ -562,7 +562,7 @@ private AssociationHandler<Neo4jPersistentProperty> populateFrom(MapAccessor que
562
562
&& propertyValueNotNull ;
563
563
564
564
if (populatedCollection ) {
565
- createInstanceOfRelationships (persistentProperty , queryResult , (RelationshipDescription ) association , baseDescription , baseDescription , relationshipsFromResult , nodesFromResult , false )
565
+ createInstanceOfRelationships (persistentProperty , queryResult , (RelationshipDescription ) association , baseDescription , relationshipsFromResult , nodesFromResult , false )
566
566
.ifPresent (value -> {
567
567
Collection <?> providedCollection = (Collection <?>) value ;
568
568
Collection <?> existingValue = (Collection <?>) propertyValue ;
@@ -585,7 +585,7 @@ private AssociationHandler<Neo4jPersistentProperty> populateFrom(MapAccessor que
585
585
return ;
586
586
}
587
587
588
- createInstanceOfRelationships (persistentProperty , queryResult , (RelationshipDescription ) association , baseDescription , baseDescription , relationshipsFromResult , nodesFromResult )
588
+ createInstanceOfRelationships (persistentProperty , queryResult , (RelationshipDescription ) association , baseDescription , relationshipsFromResult , nodesFromResult )
589
589
.ifPresent (value -> propertyAccessor .setProperty (persistentProperty , value ));
590
590
};
591
591
}
@@ -609,13 +609,13 @@ private void mergeCollections(RelationshipDescription relationshipDescription, C
609
609
}
610
610
611
611
private Optional <Object > createInstanceOfRelationships (Neo4jPersistentProperty persistentProperty , MapAccessor values ,
612
- RelationshipDescription relationshipDescription , NodeDescription <?> baseDescription , NodeDescription <?> genericNodeDescription , Collection <Relationship > relationshipsFromResult ,
612
+ RelationshipDescription relationshipDescription , NodeDescription <?> baseDescription , Collection <Relationship > relationshipsFromResult ,
613
613
Collection <Node > nodesFromResult ) {
614
- return createInstanceOfRelationships (persistentProperty , values , relationshipDescription , baseDescription , genericNodeDescription , relationshipsFromResult , nodesFromResult , true );
614
+ return createInstanceOfRelationships (persistentProperty , values , relationshipDescription , baseDescription , relationshipsFromResult , nodesFromResult , true );
615
615
}
616
616
617
617
private Optional <Object > createInstanceOfRelationships (Neo4jPersistentProperty persistentProperty , MapAccessor values ,
618
- RelationshipDescription relationshipDescription , NodeDescription <?> baseDescription , NodeDescription <?> genericNodeDescription , Collection <Relationship > relationshipsFromResult ,
618
+ RelationshipDescription relationshipDescription , NodeDescription <?> baseDescription , Collection <Relationship > relationshipsFromResult ,
619
619
Collection <Node > nodesFromResult , boolean fetchMore ) {
620
620
621
621
String typeOfRelationship = relationshipDescription .getType ();
@@ -649,8 +649,7 @@ private Optional<Object> createInstanceOfRelationships(Neo4jPersistentProperty p
649
649
mappedObjectHandler = (type , mappedObject ) -> value .add (mappedObject );
650
650
}
651
651
652
- String collectionName = relationshipDescription .generateRelatedNodesCollectionName (genericNodeDescription );
653
-
652
+ String collectionName = relationshipDescription .generateRelatedNodesCollectionName (baseDescription );
654
653
Value list = values .get (collectionName );
655
654
656
655
List <Object > relationshipsAndProperties = new ArrayList <>();
@@ -697,12 +696,12 @@ private Optional<Object> createInstanceOfRelationships(Neo4jPersistentProperty p
697
696
if (fetchMore ) {
698
697
mappedObject = sourceNodeId != null && sourceNodeId .equals (targetNodeId )
699
698
? knownObjects .getObject ("N" + sourceNodeId )
700
- : map (possibleValueNode , concreteTargetNodeDescription , genericNodeDescription , null , null , relationshipsFromResult , nodesFromResult );
699
+ : map (possibleValueNode , concreteTargetNodeDescription , baseDescription , null , null , relationshipsFromResult , nodesFromResult );
701
700
} else {
702
701
Object objectFromStore = knownObjects .getObject ("N" + targetNodeId );
703
702
mappedObject = objectFromStore != null
704
703
? objectFromStore
705
- : map (possibleValueNode , concreteTargetNodeDescription , genericNodeDescription , null , null , relationshipsFromResult , nodesFromResult );
704
+ : map (possibleValueNode , concreteTargetNodeDescription , baseDescription , null , null , relationshipsFromResult , nodesFromResult );
706
705
}
707
706
708
707
if (relationshipDescription .hasRelationshipProperties ()) {
@@ -734,16 +733,16 @@ private Optional<Object> createInstanceOfRelationships(Neo4jPersistentProperty p
734
733
735
734
Object valueEntry ;
736
735
if (fetchMore ) {
737
- valueEntry = map (relatedEntity , concreteTargetNodeDescription , genericNodeDescription , null , null , relationshipsFromResult , nodesFromResult );
736
+ valueEntry = map (relatedEntity , concreteTargetNodeDescription , genericTargetNodeDescription , null , null , relationshipsFromResult , nodesFromResult );
738
737
} else {
739
738
Object objectFromStore = knownObjects .getObject (IdentitySupport .getInternalId (relatedEntity , null ));
740
739
valueEntry = objectFromStore != null
741
740
? objectFromStore
742
- : map (relatedEntity , concreteTargetNodeDescription , genericNodeDescription , null , null , relationshipsFromResult , nodesFromResult );
741
+ : map (relatedEntity , concreteTargetNodeDescription , genericTargetNodeDescription , null , null , relationshipsFromResult , nodesFromResult );
743
742
}
744
743
745
744
if (relationshipDescription .hasRelationshipProperties ()) {
746
- String sourceLabel = relationshipDescription .getSource ().getMostAbstractParentLabel (genericNodeDescription );
745
+ String sourceLabel = relationshipDescription .getSource ().getMostAbstractParentLabel (baseDescription );
747
746
String relationshipSymbolicName = sourceLabel
748
747
+ RelationshipDescription .NAME_OF_RELATIONSHIP + targetLabel ;
749
748
Relationship relatedEntityRelationship = relatedEntity .get (relationshipSymbolicName )
0 commit comments