Я хочу обновить существующий элемент токена с помощью столбца last_accessed_on
(который является новым).Я попробовал ниже код, который не работает.
Пожалуйста, укажите мне, что здесь не так.
//dynamoDB is initialized with config and it is good.
Table table = dynamoDB.getTable("Token");
UpdateItemSpec updateItemSpec = new UpdateItemSpec()
.withPrimaryKey("GUID", "guidHashed")
.withUpdateExpression("set #name = :val1")
.withNameMap(new NameMap().with("#name", "last_accessed_on"))
.withValueMap(new ValueMap().withLong(":val1", System.currentTimeMillis()));
Ниже приведен объект DTO.
@DynamoDBTable(tableName = "Token")
public class TokenItem {
@DynamoDBHashKey(attributeName = "GUID")
private String guid;
@DynamoDBRangeKey(attributeName = "type")
private String type;
@DynamoDBAttribute(attributeName = "last_accessed_on")
private long lastAccessedOn;
//getter and setters
}
Ошибка:
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: FNEPHSAEMVJF66Q9ASUAAJG)
at com.amazonaws.http.AmazonHttpClient$RequestExecutor.handleErrorResponse(AmazonHttpClient.java:1660)
at com.amazonaws.http.AmazonHttpClient$RequestExecutor.executeOneRequest(AmazonHttpClient.java:1324)
at com.amazonaws.http.AmazonHttpClient$RequestExecutor.executeHelper(AmazonHttpClient.java:1074)
at com.amazonaws.http.AmazonHttpClient$RequestExecutor.doExecute(AmazonHttpClient.java:745)
at com.amazonaws.http.AmazonHttpClient$RequestExecutor.executeWithTimer(AmazonHttpClient.java:719)
at com.amazonaws.http.AmazonHttpClient$RequestExecutor.execute(AmazonHttpClient.java:701)
at com.amazonaws.http.AmazonHttpClient$RequestExecutor.access$500(AmazonHttpClient.java:669)
at com.amazonaws.http.AmazonHttpClient$RequestExecutionBuilderImpl.execute(AmazonHttpClient.java:651)
at com.amazonaws.http.AmazonHttpClient.execute(AmazonHttpClient.java:515)
at com.amazonaws.services.dynamodbv2.AmazonDynamoDBClient.doInvoke(AmazonDynamoDBClient.java:3768)
at com.amazonaws.services.dynamodbv2.AmazonDynamoDBClient.invoke(AmazonDynamoDBClient.java:3737)
at com.amazonaws.services.dynamodbv2.AmazonDynamoDBClient.executeUpdateItem(AmazonDynamoDBClient.java:3448)
at com.amazonaws.services.dynamodbv2.AmazonDynamoDBClient.updateItem(AmazonDynamoDBClient.java:3416)
at com.amazonaws.services.dynamodbv2.document.internal.UpdateItemImpl.doUpdateItem(UpdateItemImpl.java:102)
at com.amazonaws.services.dynamodbv2.document.internal.UpdateItemImpl.updateItem(UpdateItemImpl.java:86)
at com.amazonaws.services.dynamodbv2.document.Table.updateItem(Table.java:225)