@@ -326,7 +326,7 @@ private <ET> ET map(MapAccessor queryResult, Neo4jPersistentEntity<ET> nodeDescr
326
326
327
327
knownObjects .removeFromInCreation (internalId );
328
328
329
- populateProperties (queryResult , nodeDescription , internalId , instance , lastMappedEntity , relationshipsFromResult , nodesFromResult , false );
329
+ populateProperties (queryResult , ( Neo4jPersistentEntity < ET >) genericTargetNodeDescription , nodeDescription , internalId , instance , lastMappedEntity , relationshipsFromResult , nodesFromResult , false );
330
330
331
331
PersistentPropertyAccessor <ET > propertyAccessor = concreteNodeDescription .getPropertyAccessor (getMostCurrentInstance (internalId , instance ));
332
332
ET bean = propertyAccessor .getBean ();
@@ -351,7 +351,7 @@ private <ET> ET map(MapAccessor queryResult, Neo4jPersistentEntity<ET> nodeDescr
351
351
// AND (!!!)
352
352
// 2. mutable target types
353
353
// 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 );
355
355
}
356
356
// due to a needed side effect in `populateProperties`, the entity might have been changed
357
357
return getMostCurrentInstance (internalId , mappedObject );
@@ -363,13 +363,13 @@ private <ET> ET getMostCurrentInstance(String internalId, ET fallbackInstance) {
363
363
}
364
364
365
365
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 ,
367
367
ET mappedObject , @ Nullable Object lastMappedEntity ,
368
368
Collection <Relationship > relationshipsFromResult , Collection <Node > nodesFromResult , boolean objectAlreadyMapped ) {
369
369
370
- List <String > allLabels = getLabels (queryResult , nodeDescription );
370
+ List <String > allLabels = getLabels (queryResult , moreConcreteNodeDescription );
371
371
NodeDescriptionAndLabels nodeDescriptionAndLabels = nodeDescriptionStore
372
- .deriveConcreteNodeDescription (nodeDescription , allLabels );
372
+ .deriveConcreteNodeDescription (moreConcreteNodeDescription , allLabels );
373
373
374
374
@ SuppressWarnings ("unchecked" )
375
375
Neo4jPersistentEntity <ET > concreteNodeDescription = (Neo4jPersistentEntity <ET >) nodeDescriptionAndLabels
@@ -397,7 +397,7 @@ private <ET> void populateProperties(MapAccessor queryResult, Neo4jPersistentEnt
397
397
knownObjects .storeObject (internalId , propertyAccessor .getBean ());
398
398
399
399
AssociationHandlerSupport .of (concreteNodeDescription ).doWithAssociations (
400
- populateFrom (queryResult , nodeDescription , propertyAccessor , isConstructorParameter , objectAlreadyMapped , relationshipsFromResult , nodesFromResult ));
400
+ populateFrom (queryResult , baseNodeDescription , propertyAccessor , isConstructorParameter , objectAlreadyMapped , relationshipsFromResult , nodesFromResult ));
401
401
}
402
402
403
403
@ NonNull
@@ -469,12 +469,12 @@ public <T> T getParameterValue(Parameter<T, Neo4jPersistentProperty> parameter)
469
469
// If we cannot find any value it does not mean that there isn't any.
470
470
// The result set might contain associations not named CONCRETE_TYPE_TARGET but ABSTRACT_TYPE_TARGET.
471
471
// 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 )
473
473
.orElseGet (() -> {
474
474
NodeDescription <?> parentNodeDescription = nodeDescription .getParentNodeDescription ();
475
475
T resultValue = null ;
476
476
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 );
478
478
if (value .isPresent ()) {
479
479
resultValue = (T ) value .get ();
480
480
break ;
@@ -567,7 +567,7 @@ private AssociationHandler<Neo4jPersistentProperty> populateFrom(MapAccessor que
567
567
&& propertyValueNotNull ;
568
568
569
569
if (populatedCollection ) {
570
- createInstanceOfRelationships (persistentProperty , queryResult , (RelationshipDescription ) association , baseDescription , baseDescription , relationshipsFromResult , nodesFromResult , false )
570
+ createInstanceOfRelationships (persistentProperty , queryResult , (RelationshipDescription ) association , baseDescription , relationshipsFromResult , nodesFromResult , false )
571
571
.ifPresent (value -> {
572
572
Collection <?> providedCollection = (Collection <?>) value ;
573
573
Collection <?> existingValue = (Collection <?>) propertyValue ;
@@ -590,7 +590,7 @@ private AssociationHandler<Neo4jPersistentProperty> populateFrom(MapAccessor que
590
590
return ;
591
591
}
592
592
593
- createInstanceOfRelationships (persistentProperty , queryResult , (RelationshipDescription ) association , baseDescription , baseDescription , relationshipsFromResult , nodesFromResult )
593
+ createInstanceOfRelationships (persistentProperty , queryResult , (RelationshipDescription ) association , baseDescription , relationshipsFromResult , nodesFromResult )
594
594
.ifPresent (value -> propertyAccessor .setProperty (persistentProperty , value ));
595
595
};
596
596
}
@@ -614,13 +614,13 @@ private void mergeCollections(RelationshipDescription relationshipDescription, C
614
614
}
615
615
616
616
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 ,
618
618
Collection <Node > nodesFromResult ) {
619
- return createInstanceOfRelationships (persistentProperty , values , relationshipDescription , baseDescription , genericNodeDescription , relationshipsFromResult , nodesFromResult , true );
619
+ return createInstanceOfRelationships (persistentProperty , values , relationshipDescription , baseDescription , relationshipsFromResult , nodesFromResult , true );
620
620
}
621
621
622
622
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 ,
624
624
Collection <Node > nodesFromResult , boolean fetchMore ) {
625
625
626
626
String typeOfRelationship = relationshipDescription .getType ();
@@ -654,8 +654,7 @@ private Optional<Object> createInstanceOfRelationships(Neo4jPersistentProperty p
654
654
mappedObjectHandler = (type , mappedObject ) -> value .add (mappedObject );
655
655
}
656
656
657
- String collectionName = relationshipDescription .generateRelatedNodesCollectionName (genericNodeDescription );
658
-
657
+ String collectionName = relationshipDescription .generateRelatedNodesCollectionName (baseDescription );
659
658
Value list = values .get (collectionName );
660
659
boolean relationshipListEmptyOrNull = Values .NULL .equals (list );
661
660
@@ -715,12 +714,12 @@ private Optional<Object> createInstanceOfRelationships(Neo4jPersistentProperty p
715
714
if (fetchMore ) {
716
715
mappedObject = sourceNodeId != null && sourceNodeId .equals (targetNodeId )
717
716
? knownObjects .getObject ("N" + sourceNodeId )
718
- : map (possibleValueNode , concreteTargetNodeDescription , genericNodeDescription , null , null , relationshipsFromResult , nodesFromResult );
717
+ : map (possibleValueNode , concreteTargetNodeDescription , baseDescription , null , null , relationshipsFromResult , nodesFromResult );
719
718
} else {
720
719
Object objectFromStore = knownObjects .getObject ("N" + targetNodeId );
721
720
mappedObject = objectFromStore != null
722
721
? objectFromStore
723
- : map (possibleValueNode , concreteTargetNodeDescription , genericNodeDescription , null , null , relationshipsFromResult , nodesFromResult );
722
+ : map (possibleValueNode , concreteTargetNodeDescription , baseDescription , null , null , relationshipsFromResult , nodesFromResult );
724
723
}
725
724
726
725
if (relationshipDescription .hasRelationshipProperties ()) {
@@ -752,16 +751,16 @@ private Optional<Object> createInstanceOfRelationships(Neo4jPersistentProperty p
752
751
753
752
Object valueEntry ;
754
753
if (fetchMore ) {
755
- valueEntry = map (relatedEntity , concreteTargetNodeDescription , genericNodeDescription , null , null , relationshipsFromResult , nodesFromResult );
754
+ valueEntry = map (relatedEntity , concreteTargetNodeDescription , genericTargetNodeDescription , null , null , relationshipsFromResult , nodesFromResult );
756
755
} else {
757
756
Object objectFromStore = knownObjects .getObject (IdentitySupport .getPrefixedElementId (relatedEntity , null ));
758
757
valueEntry = objectFromStore != null
759
758
? objectFromStore
760
- : map (relatedEntity , concreteTargetNodeDescription , genericNodeDescription , null , null , relationshipsFromResult , nodesFromResult );
759
+ : map (relatedEntity , concreteTargetNodeDescription , genericTargetNodeDescription , null , null , relationshipsFromResult , nodesFromResult );
761
760
}
762
761
763
762
if (relationshipDescription .hasRelationshipProperties ()) {
764
- String sourceLabel = relationshipDescription .getSource ().getMostAbstractParentLabel (genericNodeDescription );
763
+ String sourceLabel = relationshipDescription .getSource ().getMostAbstractParentLabel (baseDescription );
765
764
String relationshipSymbolicName = sourceLabel
766
765
+ RelationshipDescription .NAME_OF_RELATIONSHIP + targetLabel ;
767
766
Relationship relatedEntityRelationship = relatedEntity .get (relationshipSymbolicName )
0 commit comments