Skip to content

Commit 95d3b63

Browse files
committed
Polishing.
Remove duplicate and unused code. See #1695
1 parent 04bf615 commit 95d3b63

File tree

3 files changed

+23
-24
lines changed

3 files changed

+23
-24
lines changed

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

-1
Original file line numberDiff line numberDiff line change
@@ -416,7 +416,6 @@ private Condition mapEmbeddedObjectCondition(CriteriaDefinition criteria, MapSql
416416

417417
PersistentPropertyAccessor<Object> embeddedAccessor = persistentEntity.getPropertyAccessor(criteria.getValue());
418418

419-
String prefix = embeddedProperty.getEmbeddedPrefix();
420419
Condition condition = null;
421420
for (RelationalPersistentProperty nestedProperty : persistentEntity) {
422421

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

+1-2
Original file line numberDiff line numberDiff line change
@@ -61,8 +61,7 @@ Table getTable(AggregatePath path) {
6161

6262
Column getColumn(AggregatePath path) {
6363
AggregatePath.ColumnInfo columnInfo = path.getColumnInfo();
64-
AggregatePath.ColumnInfo columnInfo1 = path.getColumnInfo();
65-
return getTable(path).column(columnInfo1.name()).as(columnInfo.alias());
64+
return getTable(path).column(columnInfo.name()).as(columnInfo.alias());
6665
}
6766

6867
Column getReverseColumn(AggregatePath path) {

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

+22-21
Original file line numberDiff line numberDiff line change
@@ -42,16 +42,16 @@
4242
* @author Bastian Wilhelm
4343
* @author Mark Paluch
4444
*/
45-
public class SqlGeneratorEmbeddedUnitTests {
45+
class SqlGeneratorEmbeddedUnitTests {
4646

4747
private final RelationalMappingContext context = new JdbcMappingContext();
48-
JdbcConverter converter = new MappingJdbcConverter(context, (identifier, path) -> {
48+
private JdbcConverter converter = new MappingJdbcConverter(context, (identifier, path) -> {
4949
throw new UnsupportedOperationException();
5050
});
5151
private SqlGenerator sqlGenerator;
5252

5353
@BeforeEach
54-
public void setUp() {
54+
void setUp() {
5555
this.context.setForceQuote(false);
5656
this.sqlGenerator = createSqlGenerator(DummyEntity.class);
5757
}
@@ -62,7 +62,7 @@ SqlGenerator createSqlGenerator(Class<?> type) {
6262
}
6363

6464
@Test // DATAJDBC-111
65-
public void findOne() {
65+
void findOne() {
6666
final String sql = sqlGenerator.getFindOne();
6767

6868
assertSoftly(softly -> {
@@ -85,7 +85,7 @@ public void findOne() {
8585
}
8686

8787
@Test // DATAJDBC-111
88-
public void findAll() {
88+
void findAll() {
8989
final String sql = sqlGenerator.getFindAll();
9090

9191
assertSoftly(softly -> {
@@ -108,7 +108,7 @@ public void findAll() {
108108
}
109109

110110
@Test // DATAJDBC-111
111-
public void findAllInList() {
111+
void findAllInList() {
112112
final String sql = sqlGenerator.getFindAllInList();
113113

114114
assertSoftly(softly -> {
@@ -131,7 +131,7 @@ public void findAllInList() {
131131
}
132132

133133
@Test // DATAJDBC-111
134-
public void insert() {
134+
void insert() {
135135
final String sql = sqlGenerator.getInsert(emptySet());
136136

137137
assertSoftly(softly -> {
@@ -153,7 +153,7 @@ public void insert() {
153153
}
154154

155155
@Test // DATAJDBC-111
156-
public void update() {
156+
void update() {
157157
final String sql = sqlGenerator.getUpdate();
158158

159159
assertSoftly(softly -> {
@@ -176,7 +176,7 @@ public void update() {
176176

177177
@Test // DATAJDBC-340
178178
@Disabled // this is just broken right now
179-
public void deleteByPath() {
179+
void deleteByPath() {
180180

181181
final String sql = sqlGenerator
182182
.createDeleteByPath(PersistentPropertyPathTestUtils.getPath("embedded.other", DummyEntity2.class, context));
@@ -193,15 +193,15 @@ public void deleteByPath() {
193193
}
194194

195195
@Test // DATAJDBC-340
196-
public void noJoinForEmbedded() {
196+
void noJoinForEmbedded() {
197197

198198
SqlGenerator.Join join = generateJoin("embeddable", DummyEntity.class);
199199

200200
assertThat(join).isNull();
201201
}
202202

203203
@Test // DATAJDBC-340
204-
public void columnForEmbeddedProperty() {
204+
void columnForEmbeddedProperty() {
205205

206206
assertThat(generatedColumn("embeddable.test", DummyEntity.class)) //
207207
.extracting( //
@@ -217,28 +217,28 @@ public void columnForEmbeddedProperty() {
217217
}
218218

219219
@Test // GH-1695
220-
public void columnForEmbeddedPropertyWithPrefix() {
220+
void columnForEmbeddedPropertyWithPrefix() {
221221
assertThat(generatedColumn("nested.childId", WithEmbeddedAndAggregateReference.class))
222222
.hasToString("a.nested_child_id AS nested_child_id");
223223
}
224224

225225
@Test // DATAJDBC-340
226-
public void noColumnForEmbedded() {
226+
void noColumnForEmbedded() {
227227

228228
assertThat(generatedColumn("embeddable", DummyEntity.class)) //
229229
.isNull();
230230
}
231231

232232
@Test // DATAJDBC-340
233-
public void noJoinForPrefixedEmbedded() {
233+
void noJoinForPrefixedEmbedded() {
234234

235235
SqlGenerator.Join join = generateJoin("prefixedEmbeddable", DummyEntity.class);
236236

237237
assertThat(join).isNull();
238238
}
239239

240240
@Test // DATAJDBC-340
241-
public void columnForPrefixedEmbeddedProperty() {
241+
void columnForPrefixedEmbeddedProperty() {
242242

243243
assertThat(generatedColumn("prefixedEmbeddable.test", DummyEntity.class)) //
244244
.extracting( //
@@ -254,15 +254,15 @@ public void columnForPrefixedEmbeddedProperty() {
254254
}
255255

256256
@Test // DATAJDBC-340
257-
public void noJoinForCascadedEmbedded() {
257+
void noJoinForCascadedEmbedded() {
258258

259259
SqlGenerator.Join join = generateJoin("embeddable.embeddable", DummyEntity.class);
260260

261261
assertThat(join).isNull();
262262
}
263263

264264
@Test // DATAJDBC-340
265-
public void columnForCascadedEmbeddedProperty() {
265+
void columnForCascadedEmbeddedProperty() {
266266

267267
assertThat(generatedColumn("embeddable.embeddable.attr1", DummyEntity.class)) //
268268
.extracting(c -> c.getName(), c -> c.getTable().getName(), c -> getAlias(c.getTable()), this::getAlias)
@@ -271,7 +271,7 @@ public void columnForCascadedEmbeddedProperty() {
271271
}
272272

273273
@Test // DATAJDBC-340
274-
public void joinForEmbeddedWithReference() {
274+
void joinForEmbeddedWithReference() {
275275

276276
SqlGenerator.Join join = generateJoin("embedded.other", DummyEntity2.class);
277277

@@ -286,7 +286,7 @@ public void joinForEmbeddedWithReference() {
286286
}
287287

288288
@Test // DATAJDBC-340
289-
public void columnForEmbeddedWithReferenceProperty() {
289+
void columnForEmbeddedWithReferenceProperty() {
290290

291291
assertThat(generatedColumn("embedded.other.value", DummyEntity2.class)) //
292292
.extracting( //
@@ -362,14 +362,15 @@ static class OtherEntity {
362362
}
363363

364364
@Table("a")
365+
private
365366
record WithEmbeddedAndAggregateReference(@Id long id,
366367
@Embedded.Nullable(prefix = "nested_") WithAggregateReference nested) {
367368
}
368369

369-
record WithAggregateReference(AggregateReference<Child, Long> childId) {
370+
private record WithAggregateReference(AggregateReference<Child, Long> childId) {
370371
}
371372

372-
record Child(@Id long id) {
373+
private record Child(@Id long id) {
373374

374375
}
375376

0 commit comments

Comments
 (0)