Polishing.

Original pull request #1231
See #537
This commit is contained in:
Jens Schauder
2022-06-20 15:06:14 +02:00
parent 1a283fa406
commit ed7853d2d0
6 changed files with 11 additions and 25 deletions

View File

@@ -48,7 +48,7 @@ public interface DataAccessStrategy extends RelationResolver {
* @param instance the instance to be stored. Must not be {@code null}.
* @param domainType the type of the instance. Must not be {@code null}.
* @param identifier information about data that needs to be considered for the insert but which is not part of the
* entity. Namely references back to a parent entity and key/index columns for entities that are stored in a
* entity. Namely, references back to a parent entity and key/index columns for entities that are stored in a
* {@link Map} or {@link List}.
* @return the id generated by the database if any.
* @since 1.1
@@ -66,7 +66,7 @@ public interface DataAccessStrategy extends RelationResolver {
* @param instance the instance to be stored. Must not be {@code null}.
* @param domainType the type of the instance. Must not be {@code null}.
* @param identifier information about data that needs to be considered for the insert but which is not part of the
* entity. Namely references back to a parent entity and key/index columns for entities that are stored in a
* entity. Namely, references back to a parent entity and key/index columns for entities that are stored in a
* {@link Map} or {@link List}.
* @param idValueSource the {@link IdValueSource} for the insert.
* @return the id generated by the database if any.
@@ -111,7 +111,7 @@ public interface DataAccessStrategy extends RelationResolver {
* @param previousVersion The previous version assigned to the instance being saved.
* @param <T> the type of the instance to save.
* @return whether the update actually updated a row.
* @throws OptimisticLockingFailureException if the update fails to update at least one row assuming the the
* @throws OptimisticLockingFailureException if the update fails to update at least one row assuming the
* optimistic locking version check failed.
* @since 2.0
*/
@@ -152,7 +152,7 @@ public interface DataAccessStrategy extends RelationResolver {
* @param domainType the type of entity to be deleted. Implicitly determines the table to operate on. Must not be
* {@code null}.
* @param previousVersion The previous version assigned to the instance being saved.
* @throws OptimisticLockingFailureException if the update fails to update at least one row assuming the the
* @throws OptimisticLockingFailureException if the update fails to update at least one row assuming the
* optimistic locking version check failed.
* @since 2.0
*/

View File

@@ -42,7 +42,7 @@ import org.springframework.lang.Nullable;
import org.springframework.util.Assert;
/**
* The default {@link DataAccessStrategy} is to generate SQL statements based on meta data from the entity.
* The default {@link DataAccessStrategy} is to generate SQL statements based on metadata from the entity.
*
* @author Jens Schauder
* @author Mark Paluch

View File

@@ -82,7 +82,6 @@ class SqlGenerator {
private final Lazy<String> deleteByIdSql = Lazy.of(this::createDeleteByIdSql);
private final Lazy<String> deleteByIdInSql = Lazy.of(this::createDeleteByIdInSql);
private final Lazy<String> deleteByIdAndVersionSql = Lazy.of(this::createDeleteByIdAndVersionSql);
private final Lazy<String> deleteByIdInAndVersionSql = Lazy.of(this::createDeleteByIdInAndVersionSql);
private final Lazy<String> deleteByListSql = Lazy.of(this::createDeleteByListSql);
/**
@@ -342,15 +341,6 @@ class SqlGenerator {
return deleteByIdAndVersionSql.get();
}
/**
* Create a {@code DELETE FROM … WHERE :id In … and :___oldOptimisticLockingVersion = ...} statement.
*
* @return the statement as a {@link String}. Guaranteed to be not {@literal null}.
*/
String getDeleteByIdInAndVersion() {
return deleteByIdInAndVersionSql.get();
}
/**
* Create a {@code DELETE FROM … WHERE :ids in (…)} statement.
*
@@ -682,11 +672,13 @@ class SqlGenerator {
}
private DeleteBuilder.DeleteWhereAndOr createBaseDeleteById(Table table) {
return Delete.builder().from(table)
.where(getIdColumn().isEqualTo(SQL.bindMarker(":" + renderReference(ID_SQL_PARAMETER))));
}
private DeleteBuilder.DeleteWhereAndOr createBaseDeleteByIdIn(Table table) {
return Delete.builder().from(table)
.where(getIdColumn().in(SQL.bindMarker(":" + renderReference(IDS_SQL_PARAMETER))));
}

View File

@@ -364,8 +364,9 @@ class JdbcAggregateTemplateIntegrationTests {
});
}
@Test
@Test // GH-537
void saveAndDeleteAllByAggregateRootsWithVersion() {
AggregateWithImmutableVersion aggregate1 = new AggregateWithImmutableVersion(null, null);
AggregateWithImmutableVersion aggregate2 = new AggregateWithImmutableVersion(null, null);
AggregateWithImmutableVersion aggregate3 = new AggregateWithImmutableVersion(null, null);

View File

@@ -439,7 +439,8 @@ public interface DbAction<T> {
* @since 3.0
*/
final class BatchDeleteRoot<T> extends BatchWithValue<T, DeleteRoot<T>, Class<T>> {
public BatchDeleteRoot(List<DeleteRoot<T>> actions) {
BatchDeleteRoot(List<DeleteRoot<T>> actions) {
super(actions, DeleteRoot::getEntityType);
}
}

View File

@@ -1,17 +1,9 @@
package org.springframework.data.relational.core.conversion;
import java.util.ArrayList;
import java.util.Comparator;
import java.util.HashMap;
import java.util.List;
import java.util.Map;
import java.util.function.Consumer;
import org.springframework.data.mapping.PersistentPropertyPath;
import org.springframework.data.relational.core.mapping.RelationalPersistentProperty;
import static java.util.Collections.*;
/**
* A {@link BatchingAggregateChange} implementation for delete changes that can contain actions for one or more delete
* operations. When consumed, actions are yielded in the appropriate entity tree order with deletes carried out from