1
votes

While inserting the entry into the dynamodb table, I am getting the follwing error:

com.amazonaws.services.dynamodbv2.model.ConditionalCheckFailedException: The conditional request failed (Service: AmazonDynamoDBv2; Status Code: 400; Error Code: ConditionalCheckFailedException;

This is my Java code for inserting the element:

DynamoDBSaveExpression expression = (new DynamoDBSaveExpression()).withExpectedEntry("itemKey", new ExpectedAttributeValue(false));

    try {
        this.mapper.save(itemKeyMapping, expression);
    } catch (Exception var3) {
        this.logger.error("", var3);
        throw var3;
    }

itemKeyMapping is an object which has a member variable as itemKey. So, it should work. The condition is just saying that itemKey should exist, right?

Please let me know if I am doing some mistake.

1

1 Answers

0
votes

My understanding is here was wrong. Actually, condition above means that insert only when itemKey attribute value in the database does not exist.