Skip to content

Commit ed7853d

Browse files
committed
Polishing.
Original pull request #1231 See #537
1 parent 1a283fa commit ed7853d

File tree

6 files changed

+11
-25
lines changed

6 files changed

+11
-25
lines changed

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

+4-4
Original file line numberDiff line numberDiff line change
@@ -48,7 +48,7 @@ public interface DataAccessStrategy extends RelationResolver {
4848
* @param instance the instance to be stored. Must not be {@code null}.
4949
* @param domainType the type of the instance. Must not be {@code null}.
5050
* @param identifier information about data that needs to be considered for the insert but which is not part of the
51-
* entity. Namely references back to a parent entity and key/index columns for entities that are stored in a
51+
* entity. Namely, references back to a parent entity and key/index columns for entities that are stored in a
5252
* {@link Map} or {@link List}.
5353
* @return the id generated by the database if any.
5454
* @since 1.1
@@ -66,7 +66,7 @@ public interface DataAccessStrategy extends RelationResolver {
6666
* @param instance the instance to be stored. Must not be {@code null}.
6767
* @param domainType the type of the instance. Must not be {@code null}.
6868
* @param identifier information about data that needs to be considered for the insert but which is not part of the
69-
* entity. Namely references back to a parent entity and key/index columns for entities that are stored in a
69+
* entity. Namely, references back to a parent entity and key/index columns for entities that are stored in a
7070
* {@link Map} or {@link List}.
7171
* @param idValueSource the {@link IdValueSource} for the insert.
7272
* @return the id generated by the database if any.
@@ -111,7 +111,7 @@ public interface DataAccessStrategy extends RelationResolver {
111111
* @param previousVersion The previous version assigned to the instance being saved.
112112
* @param <T> the type of the instance to save.
113113
* @return whether the update actually updated a row.
114-
* @throws OptimisticLockingFailureException if the update fails to update at least one row assuming the the
114+
* @throws OptimisticLockingFailureException if the update fails to update at least one row assuming the
115115
* optimistic locking version check failed.
116116
* @since 2.0
117117
*/
@@ -152,7 +152,7 @@ public interface DataAccessStrategy extends RelationResolver {
152152
* @param domainType the type of entity to be deleted. Implicitly determines the table to operate on. Must not be
153153
* {@code null}.
154154
* @param previousVersion The previous version assigned to the instance being saved.
155-
* @throws OptimisticLockingFailureException if the update fails to update at least one row assuming the the
155+
* @throws OptimisticLockingFailureException if the update fails to update at least one row assuming the
156156
* optimistic locking version check failed.
157157
* @since 2.0
158158
*/

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

+1-1
Original file line numberDiff line numberDiff line change
@@ -42,7 +42,7 @@
4242
import org.springframework.util.Assert;
4343

4444
/**
45-
* The default {@link DataAccessStrategy} is to generate SQL statements based on meta data from the entity.
45+
* The default {@link DataAccessStrategy} is to generate SQL statements based on metadata from the entity.
4646
*
4747
* @author Jens Schauder
4848
* @author Mark Paluch

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

+2-10
Original file line numberDiff line numberDiff line change
@@ -82,7 +82,6 @@ class SqlGenerator {
8282
private final Lazy<String> deleteByIdSql = Lazy.of(this::createDeleteByIdSql);
8383
private final Lazy<String> deleteByIdInSql = Lazy.of(this::createDeleteByIdInSql);
8484
private final Lazy<String> deleteByIdAndVersionSql = Lazy.of(this::createDeleteByIdAndVersionSql);
85-
private final Lazy<String> deleteByIdInAndVersionSql = Lazy.of(this::createDeleteByIdInAndVersionSql);
8685
private final Lazy<String> deleteByListSql = Lazy.of(this::createDeleteByListSql);
8786

8887
/**
@@ -342,15 +341,6 @@ String getDeleteByIdAndVersion() {
342341
return deleteByIdAndVersionSql.get();
343342
}
344343

345-
/**
346-
* Create a {@code DELETE FROM … WHERE :id In … and :___oldOptimisticLockingVersion = ...} statement.
347-
*
348-
* @return the statement as a {@link String}. Guaranteed to be not {@literal null}.
349-
*/
350-
String getDeleteByIdInAndVersion() {
351-
return deleteByIdInAndVersionSql.get();
352-
}
353-
354344
/**
355345
* Create a {@code DELETE FROM … WHERE :ids in (…)} statement.
356346
*
@@ -682,11 +672,13 @@ private String createDeleteByIdInAndVersionSql() {
682672
}
683673

684674
private DeleteBuilder.DeleteWhereAndOr createBaseDeleteById(Table table) {
675+
685676
return Delete.builder().from(table)
686677
.where(getIdColumn().isEqualTo(SQL.bindMarker(":" + renderReference(ID_SQL_PARAMETER))));
687678
}
688679

689680
private DeleteBuilder.DeleteWhereAndOr createBaseDeleteByIdIn(Table table) {
681+
690682
return Delete.builder().from(table)
691683
.where(getIdColumn().in(SQL.bindMarker(":" + renderReference(IDS_SQL_PARAMETER))));
692684
}

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

+2-1
Original file line numberDiff line numberDiff line change
@@ -364,8 +364,9 @@ void saveAndDeleteAllByIdsWithReferencedEntity() {
364364
});
365365
}
366366

367-
@Test
367+
@Test // GH-537
368368
void saveAndDeleteAllByAggregateRootsWithVersion() {
369+
369370
AggregateWithImmutableVersion aggregate1 = new AggregateWithImmutableVersion(null, null);
370371
AggregateWithImmutableVersion aggregate2 = new AggregateWithImmutableVersion(null, null);
371372
AggregateWithImmutableVersion aggregate3 = new AggregateWithImmutableVersion(null, null);

spring-data-relational/src/main/java/org/springframework/data/relational/core/conversion/DbAction.java

+2-1
Original file line numberDiff line numberDiff line change
@@ -439,7 +439,8 @@ public BatchDelete(List<Delete<T>> actions) {
439439
* @since 3.0
440440
*/
441441
final class BatchDeleteRoot<T> extends BatchWithValue<T, DeleteRoot<T>, Class<T>> {
442-
public BatchDeleteRoot(List<DeleteRoot<T>> actions) {
442+
443+
BatchDeleteRoot(List<DeleteRoot<T>> actions) {
443444
super(actions, DeleteRoot::getEntityType);
444445
}
445446
}

spring-data-relational/src/main/java/org/springframework/data/relational/core/conversion/DeleteBatchingAggregateChange.java

-8
Original file line numberDiff line numberDiff line change
@@ -1,17 +1,9 @@
11
package org.springframework.data.relational.core.conversion;
22

33
import java.util.ArrayList;
4-
import java.util.Comparator;
5-
import java.util.HashMap;
64
import java.util.List;
7-
import java.util.Map;
85
import java.util.function.Consumer;
96

10-
import org.springframework.data.mapping.PersistentPropertyPath;
11-
import org.springframework.data.relational.core.mapping.RelationalPersistentProperty;
12-
13-
import static java.util.Collections.*;
14-
157
/**
168
* A {@link BatchingAggregateChange} implementation for delete changes that can contain actions for one or more delete
179
* operations. When consumed, actions are yielded in the appropriate entity tree order with deletes carried out from

0 commit comments

Comments
 (0)