@@ -342,24 +342,8 @@ private <ET> void populateProperties(MapAccessor queryResult, Neo4jPersistentEnt
342
342
// store unless we temporarily put it there.
343
343
knownObjects .storeObject (internalId , mappedObject );
344
344
345
- // Fill associations
346
- // If the nodeDescription is a more abstract class as the concrete node description,
347
- // it might contain associations not named CONCRETE_TYPE_TARGET but ABSTRACT_TYPE_TARGET.
348
- // Those won't get caught by the most concrete node description.
349
- if (nodeDescription != concreteNodeDescription ) {
350
- nodeDescription .doWithAssociations (
351
- populateFrom (queryResult , propertyAccessor , isConstructorParameter , objectAlreadyMapped , relationshipsFromResult , nodesFromResult ));
352
-
353
- // check intermediate types
354
- NodeDescription <?> parentNodeDescription = concreteNodeDescription .getParentNodeDescription ();
355
- while (parentNodeDescription != null && parentNodeDescription != concreteNodeDescription ) {
356
- ((Neo4jPersistentEntity <?>) parentNodeDescription ).doWithAssociations (
357
- populateFrom (queryResult , propertyAccessor , isConstructorParameter , objectAlreadyMapped , relationshipsFromResult , nodesFromResult ));
358
- parentNodeDescription = parentNodeDescription .getParentNodeDescription ();
359
- }
360
- }
361
345
concreteNodeDescription .doWithAssociations (
362
- populateFrom (queryResult , propertyAccessor , isConstructorParameter , objectAlreadyMapped , relationshipsFromResult , nodesFromResult ));
346
+ populateFrom (queryResult , nodeDescription , propertyAccessor , isConstructorParameter , objectAlreadyMapped , relationshipsFromResult , nodesFromResult ));
363
347
}
364
348
365
349
@ Nullable
@@ -440,12 +424,12 @@ public <T> T getParameterValue(PreferredConstructor.Parameter<T, Neo4jPersistent
440
424
// If we cannot find any value it does not mean that there isn't any.
441
425
// The result set might contain associations not named CONCRETE_TYPE_TARGET but ABSTRACT_TYPE_TARGET.
442
426
// For this we bubble up the hierarchy of NodeDescriptions.
443
- result = createInstanceOfRelationships (matchingProperty , values , relationshipDescription , relationshipsFromResult , nodesFromResult , null )
427
+ result = createInstanceOfRelationships (matchingProperty , values , relationshipDescription , nodeDescription , relationshipsFromResult , nodesFromResult )
444
428
.orElseGet (() -> {
445
429
NodeDescription <?> parentNodeDescription = nodeDescription .getParentNodeDescription ();
446
430
T resultValue = null ;
447
431
while (parentNodeDescription != null ) {
448
- Optional <Object > value = createInstanceOfRelationships (matchingProperty , values , relationshipDescription , relationshipsFromResult , nodesFromResult , parentNodeDescription );
432
+ Optional <Object > value = createInstanceOfRelationships (matchingProperty , values , relationshipDescription , parentNodeDescription , relationshipsFromResult , nodesFromResult );
449
433
if (value .isPresent ()) {
450
434
resultValue = (T ) value .get ();
451
435
break ;
@@ -499,7 +483,7 @@ private static Object getValueOrDefault(boolean ownerIsKotlinType, Class<?> rawT
499
483
return value == null && !ownerIsKotlinType && rawType .isPrimitive () ? ReflectionUtils .getPrimitiveDefault (rawType ) : value ;
500
484
}
501
485
502
- private AssociationHandler <Neo4jPersistentProperty > populateFrom (MapAccessor queryResult ,
486
+ private AssociationHandler <Neo4jPersistentProperty > populateFrom (MapAccessor queryResult , NodeDescription <?> baseDescription ,
503
487
PersistentPropertyAccessor <?> propertyAccessor , Predicate <Neo4jPersistentProperty > isConstructorParameter ,
504
488
boolean objectAlreadyMapped , Collection <Relationship > relationshipsFromResult , Collection <Node > nodesFromResult ) {
505
489
@@ -542,14 +526,14 @@ private AssociationHandler<Neo4jPersistentProperty> populateFrom(MapAccessor que
542
526
return ;
543
527
}
544
528
545
- createInstanceOfRelationships (persistentProperty , queryResult , (RelationshipDescription ) association , relationshipsFromResult , nodesFromResult , null )
529
+ createInstanceOfRelationships (persistentProperty , queryResult , (RelationshipDescription ) association , baseDescription , relationshipsFromResult , nodesFromResult )
546
530
.ifPresent (value -> propertyAccessor .setProperty (persistentProperty , value ));
547
531
};
548
532
}
549
533
550
534
private Optional <Object > createInstanceOfRelationships (Neo4jPersistentProperty persistentProperty , MapAccessor values ,
551
- RelationshipDescription relationshipDescription , Collection <Relationship > relationshipsFromResult ,
552
- Collection <Node > nodesFromResult , @ Nullable NodeDescription <?> nodeDescription ) {
535
+ RelationshipDescription relationshipDescription , NodeDescription <?> baseDescription , Collection <Relationship > relationshipsFromResult ,
536
+ Collection <Node > nodesFromResult ) {
553
537
554
538
String typeOfRelationship = relationshipDescription .getType ();
555
539
String sourceLabel = relationshipDescription .getSource ().getPrimaryLabel ();
@@ -583,13 +567,7 @@ private Optional<Object> createInstanceOfRelationships(Neo4jPersistentProperty p
583
567
mappedObjectHandler = (type , mappedObject ) -> value .add (mappedObject );
584
568
}
585
569
586
- // Generate name driven by the (nullable) NodeDescription of necessary,
587
- // because it might contain associations not named CONCRETE_TYPE_TARGET but ABSTRACT_TYPE_TARGET
588
- String collectionName = relationshipDescription .generateRelatedNodesCollectionName (
589
- nodeDescription != null
590
- ? nodeDescription
591
- : relationshipDescription .getSource ()
592
- );
570
+ String collectionName = relationshipDescription .generateRelatedNodesCollectionName (baseDescription );
593
571
594
572
Value list = values .get (collectionName );
595
573
0 commit comments