Reputation: 101
I have DynamoDB table with Hashkey + RangeKey. I am facing the following error while deleting an entry for a given HashKey and RangeKey.
Tried following approaches
DynamoDBQueryExpression
that includes both HashKey + RangeKey in KeyCondition. Performed dynamoDBMapper.delete(Obj)
.HashMap<String, AttributeValue> eav = new HashMap<String, AttributeValue>();
eav.put(":v1", new AttributeValue().withS(value));
DynamoDBQueryExpression<DocumentTable> queryExpression = new DynamoDBQueryExpression<DocumentTable>()
.withKeyConditionExpression("documentId = :v1")
.withExpressionAttributeValues(eav);
List<DocumentTable> ddbResults = dynamoDBMapper.query(DocumentTable.class, queryExpression);
dynamoDBMapper.batchDelete(ddbResults);
In both the above cases I see the following exception
com.amazonaws.services.dynamodbv2.model.AmazonDynamoDBException: The provided key element does not match the schema (Service: AmazonDynamoDBv2; Status Code: 400; Error Code: ValidationException; Request ID: I12MUB0FSQNAQT6AH0RHE1B12JVV4KQNSO5AEMVJF66Q9ASUAAJG)
Upvotes: 1
Views: 432
Reputation: 1602
You tried to specify an item by giving a value for the key documentId
. The error is trying to tell you that documentId
isn't the name of the key in your table.
Replace documentId
with the name of the key in you table.
Upvotes: 0