From 9b0ca43f6c2885a54bb32daf3a886c29137c5cd4 Mon Sep 17 00:00:00 2001 From: Jens Schauder Date: Fri, 21 Nov 2025 14:36:25 +0100 Subject: [PATCH 1/2] 2176-ignore-update-count - Prepare branch --- pom.xml | 2 +- spring-data-jdbc-distribution/pom.xml | 2 +- spring-data-jdbc/pom.xml | 4 ++-- spring-data-r2dbc/pom.xml | 4 ++-- spring-data-relational/pom.xml | 4 ++-- 5 files changed, 8 insertions(+), 8 deletions(-) diff --git a/pom.xml b/pom.xml index 7a5ba63e02..7c155ec8e6 100644 --- a/pom.xml +++ b/pom.xml @@ -5,7 +5,7 @@ org.springframework.data spring-data-relational-parent - 4.1.0-SNAPSHOT + 4.1.0-2176-ignore-update-count-SNAPSHOT pom Spring Data Relational Parent diff --git a/spring-data-jdbc-distribution/pom.xml b/spring-data-jdbc-distribution/pom.xml index 824e70541b..1400b5d9f0 100644 --- a/spring-data-jdbc-distribution/pom.xml +++ b/spring-data-jdbc-distribution/pom.xml @@ -14,7 +14,7 @@ org.springframework.data spring-data-relational-parent - 4.1.0-SNAPSHOT + 4.1.0-2176-ignore-update-count-SNAPSHOT ../pom.xml diff --git a/spring-data-jdbc/pom.xml b/spring-data-jdbc/pom.xml index 87567d6220..1078d5eb52 100644 --- a/spring-data-jdbc/pom.xml +++ b/spring-data-jdbc/pom.xml @@ -6,7 +6,7 @@ 4.0.0 spring-data-jdbc - 4.1.0-SNAPSHOT + 4.1.0-2176-ignore-update-count-SNAPSHOT Spring Data JDBC Spring Data module for JDBC repositories. @@ -15,7 +15,7 @@ org.springframework.data spring-data-relational-parent - 4.1.0-SNAPSHOT + 4.1.0-2176-ignore-update-count-SNAPSHOT diff --git a/spring-data-r2dbc/pom.xml b/spring-data-r2dbc/pom.xml index b8ac584eee..9a7c0c92a5 100644 --- a/spring-data-r2dbc/pom.xml +++ b/spring-data-r2dbc/pom.xml @@ -6,7 +6,7 @@ 4.0.0 spring-data-r2dbc - 4.1.0-SNAPSHOT + 4.1.0-2176-ignore-update-count-SNAPSHOT Spring Data R2DBC Spring Data module for R2DBC @@ -15,7 +15,7 @@ org.springframework.data spring-data-relational-parent - 4.1.0-SNAPSHOT + 4.1.0-2176-ignore-update-count-SNAPSHOT diff --git a/spring-data-relational/pom.xml b/spring-data-relational/pom.xml index 652ad2853d..055af81a0a 100644 --- a/spring-data-relational/pom.xml +++ b/spring-data-relational/pom.xml @@ -6,7 +6,7 @@ 4.0.0 spring-data-relational - 4.1.0-SNAPSHOT + 4.1.0-2176-ignore-update-count-SNAPSHOT Spring Data Relational Spring Data Relational support @@ -14,7 +14,7 @@ org.springframework.data spring-data-relational-parent - 4.1.0-SNAPSHOT + 4.1.0-2176-ignore-update-count-SNAPSHOT From a1dc5f011071e10afe7003e38c5d9aed4e834948 Mon Sep 17 00:00:00 2001 From: Jens Schauder Date: Fri, 21 Nov 2025 13:43:00 +0100 Subject: [PATCH 2/2] Ignore update count without version. When an update results in 0 updated rows we now ignore it, instead of throwing an exception. The reason is that at least some databases return 0 when a row for updating was found, but none of the values changed. Closes #2176 --- .../jdbc/core/JdbcAggregateChangeExecutionContext.java | 7 +------ .../AbstractJdbcAggregateTemplateIntegrationTests.java | 5 ++--- 2 files changed, 3 insertions(+), 9 deletions(-) diff --git a/spring-data-jdbc/src/main/java/org/springframework/data/jdbc/core/JdbcAggregateChangeExecutionContext.java b/spring-data-jdbc/src/main/java/org/springframework/data/jdbc/core/JdbcAggregateChangeExecutionContext.java index b1f33efcaa..c4a6e022d2 100644 --- a/spring-data-jdbc/src/main/java/org/springframework/data/jdbc/core/JdbcAggregateChangeExecutionContext.java +++ b/spring-data-jdbc/src/main/java/org/springframework/data/jdbc/core/JdbcAggregateChangeExecutionContext.java @@ -348,12 +348,7 @@ private RelationalPersistentEntity getRequiredPersistentEntity(Class t } private void updateWithoutVersion(DbAction.UpdateRoot update) { - - if (!accessStrategy.update(update.entity(), update.getEntityType())) { - - throw new IncorrectUpdateSemanticsDataAccessException( - String.format(UPDATE_FAILED, update.entity(), getIdFrom(update))); - } + accessStrategy.update(update.entity(), update.getEntityType()); } private void updateWithVersion(DbAction.UpdateRoot update) { diff --git a/spring-data-jdbc/src/test/java/org/springframework/data/jdbc/core/AbstractJdbcAggregateTemplateIntegrationTests.java b/spring-data-jdbc/src/test/java/org/springframework/data/jdbc/core/AbstractJdbcAggregateTemplateIntegrationTests.java index a4e9877214..a7234ba9f6 100644 --- a/spring-data-jdbc/src/test/java/org/springframework/data/jdbc/core/AbstractJdbcAggregateTemplateIntegrationTests.java +++ b/spring-data-jdbc/src/test/java/org/springframework/data/jdbc/core/AbstractJdbcAggregateTemplateIntegrationTests.java @@ -579,8 +579,7 @@ void updateFailedRootDoesNotExist() { LegoSet entity = new LegoSet(); entity.id = 100L; // does not exist in the database - assertThatExceptionOfType(IncorrectUpdateSemanticsDataAccessException.class) // - .isThrownBy(() -> template.save(entity)); + assertThatCode(() -> template.save(entity)).doesNotThrowAnyException(); } @Test // DATAJDBC-112 @@ -1180,7 +1179,7 @@ void saveAndUpdateAggregateWithIdAndNullVersion() { aggregate.setVersion(null); aggregate.setId(23L); - assertThatThrownBy(() -> template.save(aggregate)).isInstanceOf(IncorrectUpdateSemanticsDataAccessException.class); + assertThatCode(() -> template.save(aggregate)).doesNotThrowAnyException(); } @Test // DATAJDBC-462