We have some existing code that calls DynamoDB using this "medium-level" Java client, and the arguments are provided through this spec class: https://docs.aws.amazon.com/AWSJavaSDK/latest/javadoc/com/amazonaws/services/dynamodbv2/document/spec/UpdateItemSpec.html. You can find many examples of how this is used here. For example:
@Override
public void announce(long stateVersion) {
Table table = dynamoDB.getTable(tableName);
UpdateItemSpec updateItemSpec = new UpdateItemSpec().withPrimaryKey("namespace", blobNamespace)
.withUpdateExpression("set #version = :ver").withNameMap(new NameMap().with("#version", "version"))
.withValueMap(new ValueMap().withNumber(":ver", stateVersion));
table.updateItem(updateItemSpec);
}
Recently DynamoDB added a feature that allows UpdateItem to return the old item data in the case of conditional check failures, by providing this arg in UpdateItem request: ReturnValuesOnConditionCheckFailure
, see https://docs.aws.amazon.com/amazondynamodb/latest/APIReference/API_UpdateItem.html.
How should I use this in UpdateItemSpec
?
I did not find documentation for this so there is nothing I can try. My goal is to be able to use ReturnValuesOnConditionCheckFailure
for debugging purpose when conditional failures happen. I d like to know if it is possible to achieve this without switching to the low-level client that uses UpdateItemRequest
instead of UpdateItemSpec
. Also, if possible, does DynamoDB plan to update this UpdateItemSpec
to support this.