Skip to content

Commit 24a1ec8

Browse files
committed
Polishing.
Simplify code. Remove redundant calls. Reformat code, remove trailing whitespaces, remove duplicate tests. See #1802 Original pull request: #1810
1 parent e9b4ce3 commit 24a1ec8

File tree

3 files changed

+9
-24
lines changed

3 files changed

+9
-24
lines changed

spring-data-jdbc/src/main/java/org/springframework/data/jdbc/core/convert/MappingJdbcConverter.java

+7-8
Original file line numberDiff line numberDiff line change
@@ -26,6 +26,7 @@
2626

2727
import org.apache.commons.logging.Log;
2828
import org.apache.commons.logging.LogFactory;
29+
2930
import org.springframework.context.ApplicationContextAware;
3031
import org.springframework.core.convert.ConverterNotFoundException;
3132
import org.springframework.core.convert.converter.Converter;
@@ -45,7 +46,6 @@
4546
import org.springframework.data.relational.core.mapping.RelationalMappingContext;
4647
import org.springframework.data.relational.core.mapping.RelationalPersistentEntity;
4748
import org.springframework.data.relational.core.mapping.RelationalPersistentProperty;
48-
import org.springframework.data.relational.core.sql.SqlIdentifier;
4949
import org.springframework.data.relational.domain.RowDocument;
5050
import org.springframework.data.util.TypeInformation;
5151
import org.springframework.lang.Nullable;
@@ -384,15 +384,14 @@ public <T> T getPropertyValue(RelationalPersistentProperty property) {
384384
// references and possibly keys, that form an id
385385
if (idDefiningParentPath.hasIdProperty()) {
386386

387-
Class<?> idType = idDefiningParentPath.getRequiredIdProperty().getActualType();
388-
//
389-
RelationalPersistentProperty requiredIdProperty = idDefiningParentPath.getRequiredIdProperty();
390-
AggregatePath idPath = idDefiningParentPath.append(requiredIdProperty);
391-
Object idValue = delegate.getValue(idPath);
387+
RelationalPersistentProperty identifier = idDefiningParentPath.getRequiredIdProperty();
388+
AggregatePath idPath = idDefiningParentPath.append(identifier);
389+
Object value = delegate.getValue(idPath);
392390

393-
Assert.state(idValue != null, "idValue must not be null at this point");
391+
Assert.state(value != null, "Identifier value must not be null at this point");
394392

395-
identifierToUse = Identifier.of(aggregatePath.getTableInfo().reverseColumnInfo().name(), idValue, idType);
393+
identifierToUse = Identifier.of(aggregatePath.getTableInfo().reverseColumnInfo().name(), value,
394+
identifier.getActualType());
396395
}
397396

398397
Iterable<Object> allByPath = relationResolver.findAllByPath(identifierToUse,

spring-data-jdbc/src/test/java/org/springframework/data/jdbc/core/AbstractJdbcAggregateTemplateIntegrationTests.java

+2-1
Original file line numberDiff line numberDiff line change
@@ -18,6 +18,7 @@
1818
import static java.util.Arrays.*;
1919
import static java.util.Collections.*;
2020
import static org.assertj.core.api.Assertions.*;
21+
import static org.assertj.core.api.SoftAssertions.*;
2122
import static org.springframework.data.jdbc.testing.TestConfiguration.*;
2223
import static org.springframework.data.jdbc.testing.TestDatabaseFeatures.Feature.*;
2324

@@ -1294,7 +1295,7 @@ void singleEntitySetChain() {
12941295
First first1Reloaded = template.findById(first1.id, First.class);
12951296
First first2Reloaded = template.findById(first2.id, First.class);
12961297

1297-
SoftAssertions.assertSoftly(softly ->{
1298+
assertSoftly(softly -> {
12981299
softly.assertThat(first1Reloaded).isEqualTo(first1);
12991300
softly.assertThat(first2Reloaded).isEqualTo(first2);
13001301
});

spring-data-relational/src/test/java/org/springframework/data/relational/core/mapping/DefaultAggregatePathUnitTests.java

-15
Original file line numberDiff line numberDiff line change
@@ -202,7 +202,6 @@ void isEmbedded() {
202202
softly.assertThat(path("second2.third").isEmbedded()).isFalse();
203203
softly.assertThat(path("second2.third2").isEmbedded()).isTrue();
204204
softly.assertThat(path("second2").isEmbedded()).isTrue();
205-
206205
});
207206
}
208207

@@ -467,20 +466,6 @@ void getEffectiveIdColumnName() {
467466
});
468467
}
469468

470-
@Test // GH-1802
471-
void dingens() {
472-
473-
assertSoftly(softly -> {
474-
475-
AggregatePath.TableInfo tableInfo = path("withId.second.third").getTableInfo();
476-
AggregatePath idDefiningParentPath = path("withId.second.third").getIdDefiningParentPath();
477-
AggregatePath.TableInfo parentTable = idDefiningParentPath.getTableInfo();
478-
softly.assertThat(tableInfo.effectiveIdColumnName())
479-
.isEqualTo(quoted("WITH_ID"));
480-
481-
});
482-
}
483-
484469
@Test // GH-1525
485470
void getLength() {
486471

0 commit comments

Comments
 (0)