Skip to content

Commit dd5b85c

Browse files
committed
[POC] Optimistic Locking for Delete Operations
1 parent ba5aaea commit dd5b85c

File tree

2 files changed

+5
-6
lines changed

2 files changed

+5
-6
lines changed

services-custom/dynamodb-enhanced/src/main/java/software/amazon/awssdk/enhanced/dynamodb/model/TransactDeleteItemEnhancedRequest.java

Lines changed: 3 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -219,18 +219,16 @@ public Builder returnValuesOnConditionCheckFailure(String returnValuesOnConditio
219219
/**
220220
* Adds optimistic locking to this transactional delete request.
221221
* <p>
222-
* This method applies a condition expression that ensures the delete operation only succeeds
223-
* if the version attribute of the item matches the provided expected value. If the condition
224-
* fails, the entire transaction will be cancelled.
222+
* This method applies a condition expression that ensures the delete operation only succeeds if the version attribute of
223+
* the item matches the provided expected value. If the condition fails, the entire transaction will be cancelled.
225224
*
226225
* @param versionValue the expected version value that must match for the delete to succeed
227226
* @param versionAttributeName the name of the version attribute in the DynamoDB table
228227
* @return a builder of this type with optimistic locking condition applied
229228
* @throws IllegalArgumentException if any parameter is null
230229
*/
231230
public Builder withOptimisticLocking(AttributeValue versionValue, String versionAttributeName) {
232-
Expression optimisticLockingCondition = OptimisticLockingHelper.createVersionCondition(versionValue, versionAttributeName);
233-
return conditionExpression(optimisticLockingCondition);
231+
return conditionExpression(OptimisticLockingHelper.createVersionCondition(versionValue, versionAttributeName));
234232
}
235233

236234
public TransactDeleteItemEnhancedRequest build() {

services-custom/dynamodb-enhanced/src/main/java/software/amazon/awssdk/enhanced/dynamodb/model/TransactWriteItemsEnhancedRequest.java

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -248,7 +248,8 @@ public <T> Builder addDeleteItem(MappedTableResource<T> mappedTableResource, Del
248248
* {@link TransactDeleteItemEnhancedRequest}.
249249
* <p>
250250
* For optimistic locking support, use
251-
* {@link TransactDeleteItemEnhancedRequest.Builder#withOptimisticLocking(software.amazon.awssdk.services.dynamodb.model.AttributeValue, String)}
251+
* {@link TransactDeleteItemEnhancedRequest.Builder#withOptimisticLocking(
252+
* software.amazon.awssdk.services.dynamodb.model.AttributeValue, String)}
252253
* to create a request with version checking conditions before adding it to the transaction.
253254
*
254255
* @param mappedTableResource the table where the key is located

0 commit comments

Comments
 (0)