diff --git a/src/main/java/org/springframework/data/couchbase/core/ReactiveInsertByIdOperationSupport.java b/src/main/java/org/springframework/data/couchbase/core/ReactiveInsertByIdOperationSupport.java index daa6287d2..6aeb31a30 100644 --- a/src/main/java/org/springframework/data/couchbase/core/ReactiveInsertByIdOperationSupport.java +++ b/src/main/java/org/springframework/data/couchbase/core/ReactiveInsertByIdOperationSupport.java @@ -127,6 +127,9 @@ private void rejectInvalidTransactionalOptions() { if (this.expiry != null) { throw new IllegalArgumentException("withExpiry is not supported in a transaction"); } + if (this.durabilityLevel != null && this.durabilityLevel != DurabilityLevel.NONE) { + throw new IllegalArgumentException("withDurability is not supported in a transaction"); + } if (this.options != null) { throw new IllegalArgumentException("withOptions is not supported in a transaction"); } diff --git a/src/main/java/org/springframework/data/couchbase/core/ReactiveRemoveByIdOperationSupport.java b/src/main/java/org/springframework/data/couchbase/core/ReactiveRemoveByIdOperationSupport.java index 9149f3616..9b4756e24 100644 --- a/src/main/java/org/springframework/data/couchbase/core/ReactiveRemoveByIdOperationSupport.java +++ b/src/main/java/org/springframework/data/couchbase/core/ReactiveRemoveByIdOperationSupport.java @@ -134,6 +134,9 @@ private void rejectInvalidTransactionalOptions() { throw new IllegalArgumentException( "withDurability PersistTo and ReplicateTo overload is not supported in a transaction"); } + if (this.durabilityLevel != null && this.durabilityLevel != DurabilityLevel.NONE) { + throw new IllegalArgumentException("withDurability is not supported in a transaction"); + } if (this.options != null) { throw new IllegalArgumentException("withOptions is not supported in a transaction"); } diff --git a/src/main/java/org/springframework/data/couchbase/core/ReactiveReplaceByIdOperationSupport.java b/src/main/java/org/springframework/data/couchbase/core/ReactiveReplaceByIdOperationSupport.java index 5cb54ce0a..a4cc67065 100644 --- a/src/main/java/org/springframework/data/couchbase/core/ReactiveReplaceByIdOperationSupport.java +++ b/src/main/java/org/springframework/data/couchbase/core/ReactiveReplaceByIdOperationSupport.java @@ -146,6 +146,9 @@ private void rejectInvalidTransactionalOptions() { if (this.expiry != null) { throw new IllegalArgumentException("withExpiry is not supported in a transaction"); } + if (this.durabilityLevel != null && this.durabilityLevel != DurabilityLevel.NONE) { + throw new IllegalArgumentException("withDurability is not supported in a transaction"); + } if (this.options != null) { throw new IllegalArgumentException("withOptions is not supported in a transaction"); } diff --git a/src/test/java/org/springframework/data/couchbase/transactions/CouchbaseTransactionalUnsettableParametersIntegrationTests.java b/src/test/java/org/springframework/data/couchbase/transactions/CouchbaseTransactionalUnsettableParametersIntegrationTests.java index 2a1c18c36..1ff2dd293 100644 --- a/src/test/java/org/springframework/data/couchbase/transactions/CouchbaseTransactionalUnsettableParametersIntegrationTests.java +++ b/src/test/java/org/springframework/data/couchbase/transactions/CouchbaseTransactionalUnsettableParametersIntegrationTests.java @@ -23,6 +23,7 @@ import java.util.function.Consumer; import java.util.function.Function; +import com.couchbase.client.core.msg.kv.DurabilityLevel; import org.junit.jupiter.api.BeforeAll; import org.junit.jupiter.api.BeforeEach; import org.junit.jupiter.api.DisplayName; @@ -53,6 +54,7 @@ * will be rejected at runtime. * * @author Graham Pople + * @author Michael Reiche */ @IgnoreWhen(missesCapabilities = Capabilities.QUERY, clusterTypes = ClusterType.MOCKED) @SpringJUnitConfig(classes = { TransactionsConfig.class, @@ -103,6 +105,14 @@ public void insertWithExpiry() { }); } + @DisplayName("Using insertById().withDurability(durabilityLevel) in a transaction is rejected at runtime") + @Test + public void insertWithDurability2() { + test((ops) -> { + ops.insertById(Person.class).withDurability(DurabilityLevel.MAJORITY).one(WalterWhite); + }); + } + @DisplayName("Using insertById().withOptions in a transaction is rejected at runtime") @Test public void insertWithOptions() { @@ -127,6 +137,14 @@ public void replaceWithExpiry() { }); } + @DisplayName("Using replaceById().withDurability(durabilityLevel) in a transaction is rejected at runtime") + @Test + public void replaceWithDurability2() { + test((ops) -> { + ops.replaceById(Person.class).withDurability(DurabilityLevel.MAJORITY).one(WalterWhite); + }); + } + @DisplayName("Using replaceById().withOptions in a transaction is rejected at runtime") @Test public void replaceWithOptions() { @@ -143,6 +161,14 @@ public void removeWithDurability() { }); } + @DisplayName("Using removeById().withDurability(durabilityLevel) in a transaction is rejected at runtime") + @Test + public void removeWithDurability2() { + test((ops) -> { + ops.removeById(Person.class).withDurability(DurabilityLevel.MAJORITY).oneEntity(WalterWhite); + }); + } + @DisplayName("Using removeById().withOptions in a transaction is rejected at runtime") @Test public void removeWithOptions() {