@@ -326,7 +326,7 @@ private <ET> ET map(MapAccessor queryResult, Neo4jPersistentEntity<ET> nodeDescr
326326
327327 knownObjects .removeFromInCreation (internalId );
328328
329- populateProperties (queryResult , nodeDescription , internalId , instance , lastMappedEntity , relationshipsFromResult , nodesFromResult , false );
329+ populateProperties (queryResult , ( Neo4jPersistentEntity < ET >) genericTargetNodeDescription , nodeDescription , internalId , instance , lastMappedEntity , relationshipsFromResult , nodesFromResult , false );
330330
331331 PersistentPropertyAccessor <ET > propertyAccessor = concreteNodeDescription .getPropertyAccessor (getMostCurrentInstance (internalId , instance ));
332332 ET bean = propertyAccessor .getBean ();
@@ -351,7 +351,7 @@ private <ET> ET map(MapAccessor queryResult, Neo4jPersistentEntity<ET> nodeDescr
351351 // AND (!!!)
352352 // 2. mutable target types
353353 // because we cannot just create new instances
354- populateProperties (queryResult , nodeDescription , internalId , mappedObject , lastMappedEntity , relationshipsFromResult , nodesFromResult , true );
354+ populateProperties (queryResult , ( Neo4jPersistentEntity < ET >) genericTargetNodeDescription , nodeDescription , internalId , mappedObject , lastMappedEntity , relationshipsFromResult , nodesFromResult , true );
355355 }
356356 // due to a needed side effect in `populateProperties`, the entity might have been changed
357357 return getMostCurrentInstance (internalId , mappedObject );
@@ -363,13 +363,13 @@ private <ET> ET getMostCurrentInstance(String internalId, ET fallbackInstance) {
363363 }
364364
365365
366- private <ET > void populateProperties (MapAccessor queryResult , Neo4jPersistentEntity <ET > nodeDescription , String internalId ,
366+ private <ET > void populateProperties (MapAccessor queryResult , Neo4jPersistentEntity <ET > baseNodeDescription , Neo4jPersistentEntity < ET > moreConcreteNodeDescription , String internalId ,
367367 ET mappedObject , @ Nullable Object lastMappedEntity ,
368368 Collection <Relationship > relationshipsFromResult , Collection <Node > nodesFromResult , boolean objectAlreadyMapped ) {
369369
370- List <String > allLabels = getLabels (queryResult , nodeDescription );
370+ List <String > allLabels = getLabels (queryResult , moreConcreteNodeDescription );
371371 NodeDescriptionAndLabels nodeDescriptionAndLabels = nodeDescriptionStore
372- .deriveConcreteNodeDescription (nodeDescription , allLabels );
372+ .deriveConcreteNodeDescription (moreConcreteNodeDescription , allLabels );
373373
374374 @ SuppressWarnings ("unchecked" )
375375 Neo4jPersistentEntity <ET > concreteNodeDescription = (Neo4jPersistentEntity <ET >) nodeDescriptionAndLabels
@@ -397,7 +397,7 @@ private <ET> void populateProperties(MapAccessor queryResult, Neo4jPersistentEnt
397397 knownObjects .storeObject (internalId , propertyAccessor .getBean ());
398398
399399 AssociationHandlerSupport .of (concreteNodeDescription ).doWithAssociations (
400- populateFrom (queryResult , nodeDescription , propertyAccessor , isConstructorParameter , objectAlreadyMapped , relationshipsFromResult , nodesFromResult ));
400+ populateFrom (queryResult , baseNodeDescription , propertyAccessor , isConstructorParameter , objectAlreadyMapped , relationshipsFromResult , nodesFromResult ));
401401 }
402402
403403 @ NonNull
@@ -469,12 +469,12 @@ public <T> T getParameterValue(Parameter<T, Neo4jPersistentProperty> parameter)
469469 // If we cannot find any value it does not mean that there isn't any.
470470 // The result set might contain associations not named CONCRETE_TYPE_TARGET but ABSTRACT_TYPE_TARGET.
471471 // For this we bubble up the hierarchy of NodeDescriptions.
472- result = createInstanceOfRelationships (matchingProperty , values , relationshipDescription , nodeDescription , genericNodeDescription , relationshipsFromResult , nodesFromResult )
472+ result = createInstanceOfRelationships (matchingProperty , values , relationshipDescription , genericNodeDescription , relationshipsFromResult , nodesFromResult )
473473 .orElseGet (() -> {
474474 NodeDescription <?> parentNodeDescription = nodeDescription .getParentNodeDescription ();
475475 T resultValue = null ;
476476 while (parentNodeDescription != null ) {
477- Optional <Object > value = createInstanceOfRelationships (matchingProperty , values , relationshipDescription , parentNodeDescription , parentNodeDescription , relationshipsFromResult , nodesFromResult );
477+ Optional <Object > value = createInstanceOfRelationships (matchingProperty , values , relationshipDescription , parentNodeDescription , relationshipsFromResult , nodesFromResult );
478478 if (value .isPresent ()) {
479479 resultValue = (T ) value .get ();
480480 break ;
@@ -567,7 +567,7 @@ private AssociationHandler<Neo4jPersistentProperty> populateFrom(MapAccessor que
567567 && propertyValueNotNull ;
568568
569569 if (populatedCollection ) {
570- createInstanceOfRelationships (persistentProperty , queryResult , (RelationshipDescription ) association , baseDescription , baseDescription , relationshipsFromResult , nodesFromResult , false )
570+ createInstanceOfRelationships (persistentProperty , queryResult , (RelationshipDescription ) association , baseDescription , relationshipsFromResult , nodesFromResult , false )
571571 .ifPresent (value -> {
572572 Collection <?> providedCollection = (Collection <?>) value ;
573573 Collection <?> existingValue = (Collection <?>) propertyValue ;
@@ -590,7 +590,7 @@ private AssociationHandler<Neo4jPersistentProperty> populateFrom(MapAccessor que
590590 return ;
591591 }
592592
593- createInstanceOfRelationships (persistentProperty , queryResult , (RelationshipDescription ) association , baseDescription , baseDescription , relationshipsFromResult , nodesFromResult )
593+ createInstanceOfRelationships (persistentProperty , queryResult , (RelationshipDescription ) association , baseDescription , relationshipsFromResult , nodesFromResult )
594594 .ifPresent (value -> propertyAccessor .setProperty (persistentProperty , value ));
595595 };
596596 }
@@ -614,13 +614,13 @@ private void mergeCollections(RelationshipDescription relationshipDescription, C
614614 }
615615
616616 private Optional <Object > createInstanceOfRelationships (Neo4jPersistentProperty persistentProperty , MapAccessor values ,
617- RelationshipDescription relationshipDescription , NodeDescription <?> baseDescription , NodeDescription <?> genericNodeDescription , Collection <Relationship > relationshipsFromResult ,
617+ RelationshipDescription relationshipDescription , NodeDescription <?> baseDescription , Collection <Relationship > relationshipsFromResult ,
618618 Collection <Node > nodesFromResult ) {
619- return createInstanceOfRelationships (persistentProperty , values , relationshipDescription , baseDescription , genericNodeDescription , relationshipsFromResult , nodesFromResult , true );
619+ return createInstanceOfRelationships (persistentProperty , values , relationshipDescription , baseDescription , relationshipsFromResult , nodesFromResult , true );
620620 }
621621
622622 private Optional <Object > createInstanceOfRelationships (Neo4jPersistentProperty persistentProperty , MapAccessor values ,
623- RelationshipDescription relationshipDescription , NodeDescription <?> baseDescription , NodeDescription <?> genericNodeDescription , Collection <Relationship > relationshipsFromResult ,
623+ RelationshipDescription relationshipDescription , NodeDescription <?> baseDescription , Collection <Relationship > relationshipsFromResult ,
624624 Collection <Node > nodesFromResult , boolean fetchMore ) {
625625
626626 String typeOfRelationship = relationshipDescription .getType ();
@@ -654,8 +654,7 @@ private Optional<Object> createInstanceOfRelationships(Neo4jPersistentProperty p
654654 mappedObjectHandler = (type , mappedObject ) -> value .add (mappedObject );
655655 }
656656
657- String collectionName = relationshipDescription .generateRelatedNodesCollectionName (genericNodeDescription );
658-
657+ String collectionName = relationshipDescription .generateRelatedNodesCollectionName (baseDescription );
659658 Value list = values .get (collectionName );
660659 boolean relationshipListEmptyOrNull = Values .NULL .equals (list );
661660
@@ -715,12 +714,12 @@ private Optional<Object> createInstanceOfRelationships(Neo4jPersistentProperty p
715714 if (fetchMore ) {
716715 mappedObject = sourceNodeId != null && sourceNodeId .equals (targetNodeId )
717716 ? knownObjects .getObject ("N" + sourceNodeId )
718- : map (possibleValueNode , concreteTargetNodeDescription , genericNodeDescription , null , null , relationshipsFromResult , nodesFromResult );
717+ : map (possibleValueNode , concreteTargetNodeDescription , baseDescription , null , null , relationshipsFromResult , nodesFromResult );
719718 } else {
720719 Object objectFromStore = knownObjects .getObject ("N" + targetNodeId );
721720 mappedObject = objectFromStore != null
722721 ? objectFromStore
723- : map (possibleValueNode , concreteTargetNodeDescription , genericNodeDescription , null , null , relationshipsFromResult , nodesFromResult );
722+ : map (possibleValueNode , concreteTargetNodeDescription , baseDescription , null , null , relationshipsFromResult , nodesFromResult );
724723 }
725724
726725 if (relationshipDescription .hasRelationshipProperties ()) {
@@ -752,16 +751,16 @@ private Optional<Object> createInstanceOfRelationships(Neo4jPersistentProperty p
752751
753752 Object valueEntry ;
754753 if (fetchMore ) {
755- valueEntry = map (relatedEntity , concreteTargetNodeDescription , genericNodeDescription , null , null , relationshipsFromResult , nodesFromResult );
754+ valueEntry = map (relatedEntity , concreteTargetNodeDescription , genericTargetNodeDescription , null , null , relationshipsFromResult , nodesFromResult );
756755 } else {
757756 Object objectFromStore = knownObjects .getObject (IdentitySupport .getPrefixedElementId (relatedEntity , null ));
758757 valueEntry = objectFromStore != null
759758 ? objectFromStore
760- : map (relatedEntity , concreteTargetNodeDescription , genericNodeDescription , null , null , relationshipsFromResult , nodesFromResult );
759+ : map (relatedEntity , concreteTargetNodeDescription , genericTargetNodeDescription , null , null , relationshipsFromResult , nodesFromResult );
761760 }
762761
763762 if (relationshipDescription .hasRelationshipProperties ()) {
764- String sourceLabel = relationshipDescription .getSource ().getMostAbstractParentLabel (genericNodeDescription );
763+ String sourceLabel = relationshipDescription .getSource ().getMostAbstractParentLabel (baseDescription );
765764 String relationshipSymbolicName = sourceLabel
766765 + RelationshipDescription .NAME_OF_RELATIONSHIP + targetLabel ;
767766 Relationship relatedEntityRelationship = relatedEntity .get (relationshipSymbolicName )
0 commit comments