diff --git a/spring-data-jdbc/src/main/java/org/springframework/data/jdbc/core/convert/MappingJdbcConverter.java b/spring-data-jdbc/src/main/java/org/springframework/data/jdbc/core/convert/MappingJdbcConverter.java index 56b117f216b..106c002a51a 100644 --- a/spring-data-jdbc/src/main/java/org/springframework/data/jdbc/core/convert/MappingJdbcConverter.java +++ b/spring-data-jdbc/src/main/java/org/springframework/data/jdbc/core/convert/MappingJdbcConverter.java @@ -26,6 +26,7 @@ import org.apache.commons.logging.Log; import org.apache.commons.logging.LogFactory; + import org.springframework.context.ApplicationContextAware; import org.springframework.core.convert.ConverterNotFoundException; import org.springframework.core.convert.converter.Converter; @@ -45,7 +46,6 @@ import org.springframework.data.relational.core.mapping.RelationalMappingContext; import org.springframework.data.relational.core.mapping.RelationalPersistentEntity; import org.springframework.data.relational.core.mapping.RelationalPersistentProperty; -import org.springframework.data.relational.core.sql.SqlIdentifier; import org.springframework.data.relational.domain.RowDocument; import org.springframework.data.util.TypeInformation; import org.springframework.lang.Nullable; @@ -384,15 +384,14 @@ public T getPropertyValue(RelationalPersistentProperty property) { // references and possibly keys, that form an id if (idDefiningParentPath.hasIdProperty()) { - Class idType = idDefiningParentPath.getRequiredIdProperty().getActualType(); - // - RelationalPersistentProperty requiredIdProperty = idDefiningParentPath.getRequiredIdProperty(); - AggregatePath idPath = idDefiningParentPath.append(requiredIdProperty); - Object idValue = delegate.getValue(idPath); + RelationalPersistentProperty identifier = idDefiningParentPath.getRequiredIdProperty(); + AggregatePath idPath = idDefiningParentPath.append(identifier); + Object value = delegate.getValue(idPath); - Assert.state(idValue != null, "idValue must not be null at this point"); + Assert.state(value != null, "Identifier value must not be null at this point"); - identifierToUse = Identifier.of(aggregatePath.getTableInfo().reverseColumnInfo().name(), idValue, idType); + identifierToUse = Identifier.of(aggregatePath.getTableInfo().reverseColumnInfo().name(), value, + identifier.getActualType()); } Iterable allByPath = relationResolver.findAllByPath(identifierToUse, diff --git a/spring-data-jdbc/src/test/java/org/springframework/data/jdbc/core/AbstractJdbcAggregateTemplateIntegrationTests.java b/spring-data-jdbc/src/test/java/org/springframework/data/jdbc/core/AbstractJdbcAggregateTemplateIntegrationTests.java index f2927c16a78..0abe37a04d6 100644 --- a/spring-data-jdbc/src/test/java/org/springframework/data/jdbc/core/AbstractJdbcAggregateTemplateIntegrationTests.java +++ b/spring-data-jdbc/src/test/java/org/springframework/data/jdbc/core/AbstractJdbcAggregateTemplateIntegrationTests.java @@ -18,6 +18,7 @@ import static java.util.Arrays.*; import static java.util.Collections.*; import static org.assertj.core.api.Assertions.*; +import static org.assertj.core.api.SoftAssertions.*; import static org.springframework.data.jdbc.testing.TestConfiguration.*; import static org.springframework.data.jdbc.testing.TestDatabaseFeatures.Feature.*; @@ -1294,7 +1295,7 @@ void singleEntitySetChain() { First first1Reloaded = template.findById(first1.id, First.class); First first2Reloaded = template.findById(first2.id, First.class); - SoftAssertions.assertSoftly(softly ->{ + assertSoftly(softly -> { softly.assertThat(first1Reloaded).isEqualTo(first1); softly.assertThat(first2Reloaded).isEqualTo(first2); }); diff --git a/spring-data-relational/src/test/java/org/springframework/data/relational/core/mapping/DefaultAggregatePathUnitTests.java b/spring-data-relational/src/test/java/org/springframework/data/relational/core/mapping/DefaultAggregatePathUnitTests.java index 465a946b43f..837cec98328 100644 --- a/spring-data-relational/src/test/java/org/springframework/data/relational/core/mapping/DefaultAggregatePathUnitTests.java +++ b/spring-data-relational/src/test/java/org/springframework/data/relational/core/mapping/DefaultAggregatePathUnitTests.java @@ -202,7 +202,6 @@ void isEmbedded() { softly.assertThat(path("second2.third").isEmbedded()).isFalse(); softly.assertThat(path("second2.third2").isEmbedded()).isTrue(); softly.assertThat(path("second2").isEmbedded()).isTrue(); - }); } @@ -467,20 +466,6 @@ void getEffectiveIdColumnName() { }); } - @Test // GH-1802 - void dingens() { - - assertSoftly(softly -> { - - AggregatePath.TableInfo tableInfo = path("withId.second.third").getTableInfo(); - AggregatePath idDefiningParentPath = path("withId.second.third").getIdDefiningParentPath(); - AggregatePath.TableInfo parentTable = idDefiningParentPath.getTableInfo(); - softly.assertThat(tableInfo.effectiveIdColumnName()) - .isEqualTo(quoted("WITH_ID")); - - }); - } - @Test // GH-1525 void getLength() {