|
26 | 26 |
|
27 | 27 | import org.apache.commons.logging.Log;
|
28 | 28 | import org.apache.commons.logging.LogFactory;
|
29 |
| - |
30 | 29 | import org.springframework.context.ApplicationContextAware;
|
31 | 30 | import org.springframework.core.convert.ConverterNotFoundException;
|
32 | 31 | import org.springframework.core.convert.converter.Converter;
|
|
45 | 44 | import org.springframework.data.relational.core.mapping.RelationalMappingContext;
|
46 | 45 | import org.springframework.data.relational.core.mapping.RelationalPersistentEntity;
|
47 | 46 | import org.springframework.data.relational.core.mapping.RelationalPersistentProperty;
|
| 47 | +import org.springframework.data.relational.core.sql.SqlIdentifier; |
48 | 48 | import org.springframework.data.relational.domain.RowDocument;
|
49 | 49 | import org.springframework.data.util.TypeInformation;
|
50 | 50 | import org.springframework.lang.Nullable;
|
@@ -366,15 +366,19 @@ public <T> T getPropertyValue(RelationalPersistentProperty property) {
|
366 | 366 | if (property.isCollectionLike() || property.isMap()) {
|
367 | 367 |
|
368 | 368 | Identifier identifierToUse = this.identifier;
|
| 369 | + AggregatePath idDefiningParentPath = aggregatePath.getIdDefiningParentPath(); |
| 370 | + |
| 371 | + // note that the idDefiningParentPath might not itself have an id property, but have a combination of back |
| 372 | + // references and possibly keys, that form an id |
| 373 | + if (idDefiningParentPath.hasIdProperty()) { |
369 | 374 |
|
370 |
| - if (property.getOwner().hasIdProperty()) { |
| 375 | + Class<?> idType = idDefiningParentPath.getRequiredIdProperty().getActualType(); |
| 376 | + SqlIdentifier parentId = idDefiningParentPath.getTableInfo().idColumnName(); |
| 377 | + Object idValue = this.identifier.get(parentId); |
371 | 378 |
|
372 |
| - Object id = this.identifier.get(property.getOwner().getRequiredIdProperty().getColumnName()); |
| 379 | + Assert.state(idValue != null, "idValue must not be null at this point"); |
373 | 380 |
|
374 |
| - if (id != null) { |
375 |
| - identifierToUse = Identifier.of(aggregatePath.getTableInfo().reverseColumnInfo().name(), id, |
376 |
| - Object.class); |
377 |
| - } |
| 381 | + identifierToUse = Identifier.of(aggregatePath.getTableInfo().reverseColumnInfo().name(), idValue, idType); |
378 | 382 | }
|
379 | 383 |
|
380 | 384 | Iterable<Object> allByPath = relationResolver.findAllByPath(identifierToUse,
|
|
0 commit comments