@@ -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
|
||||
*/
|
||||
|
||||
@@ -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
|
||||
|
||||
@@ -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))));
|
||||
}
|
||||
|
||||
@@ -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);
|
||||
|
||||
Reference in New Issue
Block a user