@@ -302,6 +302,7 @@ private <ET> ET map(MapAccessor queryResult, MapAccessor allValues, Neo4jPersist
302
302
return map (queryResult , nodeDescription , nodeDescription , null , null , relationshipsFromResult , nodesFromResult );
303
303
}
304
304
305
+ @ SuppressWarnings ("unchecked" )
305
306
private <ET > ET map (MapAccessor queryResult , Neo4jPersistentEntity <ET > nodeDescription , NodeDescription <?> genericTargetNodeDescription ,
306
307
@ Nullable Object lastMappedEntity , @ Nullable RelationshipDescription relationshipDescription , Collection <Relationship > relationshipsFromResult , Collection <Node > nodesFromResult ) {
307
308
@@ -324,7 +325,7 @@ private <ET> ET map(MapAccessor queryResult, Neo4jPersistentEntity<ET> nodeDescr
324
325
325
326
knownObjects .removeFromInCreation (internalId );
326
327
327
- populateProperties (queryResult , nodeDescription , internalId , instance , lastMappedEntity , relationshipsFromResult , nodesFromResult , false );
328
+ populateProperties (queryResult , ( Neo4jPersistentEntity < ET >) genericTargetNodeDescription , nodeDescription , internalId , instance , lastMappedEntity , relationshipsFromResult , nodesFromResult , false );
328
329
329
330
PersistentPropertyAccessor <ET > propertyAccessor = concreteNodeDescription .getPropertyAccessor (instance );
330
331
ET bean = propertyAccessor .getBean ();
@@ -349,19 +350,19 @@ private <ET> ET map(MapAccessor queryResult, Neo4jPersistentEntity<ET> nodeDescr
349
350
// AND (!!!)
350
351
// 2. mutable target types
351
352
// because we cannot just create new instances
352
- populateProperties (queryResult , nodeDescription , internalId , mappedObject , lastMappedEntity , relationshipsFromResult , nodesFromResult , true );
353
+ populateProperties (queryResult , ( Neo4jPersistentEntity < ET >) genericTargetNodeDescription , nodeDescription , internalId , mappedObject , lastMappedEntity , relationshipsFromResult , nodesFromResult , true );
353
354
}
354
355
return mappedObject ;
355
356
}
356
357
357
358
358
- private <ET > void populateProperties (MapAccessor queryResult , Neo4jPersistentEntity <ET > nodeDescription , String internalId ,
359
+ private <ET > void populateProperties (MapAccessor queryResult , Neo4jPersistentEntity <ET > baseNodeDescription , Neo4jPersistentEntity < ET > moreConcreteNodeDescription , String internalId ,
359
360
ET mappedObject , @ Nullable Object lastMappedEntity ,
360
361
Collection <Relationship > relationshipsFromResult , Collection <Node > nodesFromResult , boolean objectAlreadyMapped ) {
361
362
362
- List <String > allLabels = getLabels (queryResult , nodeDescription );
363
+ List <String > allLabels = getLabels (queryResult , moreConcreteNodeDescription );
363
364
NodeDescriptionAndLabels nodeDescriptionAndLabels = nodeDescriptionStore
364
- .deriveConcreteNodeDescription (nodeDescription , allLabels );
365
+ .deriveConcreteNodeDescription (moreConcreteNodeDescription , allLabels );
365
366
366
367
@ SuppressWarnings ("unchecked" )
367
368
Neo4jPersistentEntity <ET > concreteNodeDescription = (Neo4jPersistentEntity <ET >) nodeDescriptionAndLabels
@@ -389,7 +390,7 @@ private <ET> void populateProperties(MapAccessor queryResult, Neo4jPersistentEnt
389
390
knownObjects .storeObject (internalId , mappedObject );
390
391
391
392
AssociationHandlerSupport .of (concreteNodeDescription ).doWithAssociations (
392
- populateFrom (queryResult , nodeDescription , propertyAccessor , isConstructorParameter , objectAlreadyMapped , relationshipsFromResult , nodesFromResult ));
393
+ populateFrom (queryResult , baseNodeDescription , propertyAccessor , isConstructorParameter , objectAlreadyMapped , relationshipsFromResult , nodesFromResult ));
393
394
}
394
395
395
396
@ Nullable
@@ -488,12 +489,12 @@ public <T> T getParameterValue(Parameter<T, Neo4jPersistentProperty> parameter)
488
489
// If we cannot find any value it does not mean that there isn't any.
489
490
// The result set might contain associations not named CONCRETE_TYPE_TARGET but ABSTRACT_TYPE_TARGET.
490
491
// For this we bubble up the hierarchy of NodeDescriptions.
491
- result = createInstanceOfRelationships (matchingProperty , values , relationshipDescription , nodeDescription , genericNodeDescription , relationshipsFromResult , nodesFromResult )
492
+ result = createInstanceOfRelationships (matchingProperty , values , relationshipDescription , genericNodeDescription , relationshipsFromResult , nodesFromResult )
492
493
.orElseGet (() -> {
493
494
NodeDescription <?> parentNodeDescription = nodeDescription .getParentNodeDescription ();
494
495
T resultValue = null ;
495
496
while (parentNodeDescription != null ) {
496
- Optional <Object > value = createInstanceOfRelationships (matchingProperty , values , relationshipDescription , parentNodeDescription , parentNodeDescription , relationshipsFromResult , nodesFromResult );
497
+ Optional <Object > value = createInstanceOfRelationships (matchingProperty , values , relationshipDescription , parentNodeDescription , relationshipsFromResult , nodesFromResult );
497
498
if (value .isPresent ()) {
498
499
resultValue = (T ) value .get ();
499
500
break ;
@@ -586,7 +587,7 @@ private AssociationHandler<Neo4jPersistentProperty> populateFrom(MapAccessor que
586
587
&& propertyValueNotNull ;
587
588
588
589
if (populatedCollection ) {
589
- createInstanceOfRelationships (persistentProperty , queryResult , (RelationshipDescription ) association , baseDescription , baseDescription , relationshipsFromResult , nodesFromResult , false )
590
+ createInstanceOfRelationships (persistentProperty , queryResult , (RelationshipDescription ) association , baseDescription , relationshipsFromResult , nodesFromResult , false )
590
591
.ifPresent (value -> {
591
592
Collection <?> providedCollection = (Collection <?>) value ;
592
593
Collection <?> existingValue = (Collection <?>) propertyValue ;
@@ -609,7 +610,7 @@ private AssociationHandler<Neo4jPersistentProperty> populateFrom(MapAccessor que
609
610
return ;
610
611
}
611
612
612
- createInstanceOfRelationships (persistentProperty , queryResult , (RelationshipDescription ) association , baseDescription , baseDescription , relationshipsFromResult , nodesFromResult )
613
+ createInstanceOfRelationships (persistentProperty , queryResult , (RelationshipDescription ) association , baseDescription , relationshipsFromResult , nodesFromResult )
613
614
.ifPresent (value -> propertyAccessor .setProperty (persistentProperty , value ));
614
615
};
615
616
}
@@ -633,13 +634,13 @@ private void mergeCollections(RelationshipDescription relationshipDescription, C
633
634
}
634
635
635
636
private Optional <Object > createInstanceOfRelationships (Neo4jPersistentProperty persistentProperty , MapAccessor values ,
636
- RelationshipDescription relationshipDescription , NodeDescription <?> baseDescription , NodeDescription <?> genericNodeDescription , Collection <Relationship > relationshipsFromResult ,
637
+ RelationshipDescription relationshipDescription , NodeDescription <?> baseDescription , Collection <Relationship > relationshipsFromResult ,
637
638
Collection <Node > nodesFromResult ) {
638
- return createInstanceOfRelationships (persistentProperty , values , relationshipDescription , baseDescription , genericNodeDescription , relationshipsFromResult , nodesFromResult , true );
639
+ return createInstanceOfRelationships (persistentProperty , values , relationshipDescription , baseDescription , relationshipsFromResult , nodesFromResult , true );
639
640
}
640
641
641
642
private Optional <Object > createInstanceOfRelationships (Neo4jPersistentProperty persistentProperty , MapAccessor values ,
642
- RelationshipDescription relationshipDescription , NodeDescription <?> baseDescription , NodeDescription <?> genericNodeDescription , Collection <Relationship > relationshipsFromResult ,
643
+ RelationshipDescription relationshipDescription , NodeDescription <?> baseDescription , Collection <Relationship > relationshipsFromResult ,
643
644
Collection <Node > nodesFromResult , boolean fetchMore ) {
644
645
645
646
String typeOfRelationship = relationshipDescription .getType ();
@@ -673,8 +674,7 @@ private Optional<Object> createInstanceOfRelationships(Neo4jPersistentProperty p
673
674
mappedObjectHandler = (type , mappedObject ) -> value .add (mappedObject );
674
675
}
675
676
676
- String collectionName = relationshipDescription .generateRelatedNodesCollectionName (genericNodeDescription );
677
-
677
+ String collectionName = relationshipDescription .generateRelatedNodesCollectionName (baseDescription );
678
678
Value list = values .get (collectionName );
679
679
680
680
List <Object > relationshipsAndProperties = new ArrayList <>();
@@ -720,12 +720,12 @@ private Optional<Object> createInstanceOfRelationships(Neo4jPersistentProperty p
720
720
if (fetchMore ) {
721
721
mappedObject = sourceNodeId != null && sourceNodeId .equals (targetNodeId )
722
722
? knownObjects .getObject ("N" + sourceNodeId )
723
- : map (possibleValueNode , concreteTargetNodeDescription , genericNodeDescription , null , null , relationshipsFromResult , nodesFromResult );
723
+ : map (possibleValueNode , concreteTargetNodeDescription , baseDescription , null , null , relationshipsFromResult , nodesFromResult );
724
724
} else {
725
725
Object objectFromStore = knownObjects .getObject ("N" + targetNodeId );
726
726
mappedObject = objectFromStore != null
727
727
? objectFromStore
728
- : map (possibleValueNode , concreteTargetNodeDescription , genericNodeDescription , null , null , relationshipsFromResult , nodesFromResult );
728
+ : map (possibleValueNode , concreteTargetNodeDescription , baseDescription , null , null , relationshipsFromResult , nodesFromResult );
729
729
}
730
730
731
731
if (relationshipDescription .hasRelationshipProperties ()) {
@@ -757,16 +757,16 @@ private Optional<Object> createInstanceOfRelationships(Neo4jPersistentProperty p
757
757
758
758
Object valueEntry ;
759
759
if (fetchMore ) {
760
- valueEntry = map (relatedEntity , concreteTargetNodeDescription , genericNodeDescription , null , null , relationshipsFromResult , nodesFromResult );
760
+ valueEntry = map (relatedEntity , concreteTargetNodeDescription , genericTargetNodeDescription , null , null , relationshipsFromResult , nodesFromResult );
761
761
} else {
762
762
Object objectFromStore = knownObjects .getObject (getInternalId (relatedEntity , null ));
763
763
valueEntry = objectFromStore != null
764
764
? objectFromStore
765
- : map (relatedEntity , concreteTargetNodeDescription , genericNodeDescription , null , null , relationshipsFromResult , nodesFromResult );
765
+ : map (relatedEntity , concreteTargetNodeDescription , genericTargetNodeDescription , null , null , relationshipsFromResult , nodesFromResult );
766
766
}
767
767
768
768
if (relationshipDescription .hasRelationshipProperties ()) {
769
- String sourceLabel = relationshipDescription .getSource ().getMostAbstractParentLabel (genericNodeDescription );
769
+ String sourceLabel = relationshipDescription .getSource ().getMostAbstractParentLabel (baseDescription );
770
770
String relationshipSymbolicName = sourceLabel
771
771
+ RelationshipDescription .NAME_OF_RELATIONSHIP + targetLabel ;
772
772
Relationship relatedEntityRelationship = relatedEntity .get (relationshipSymbolicName )
0 commit comments