[英]AWS JAVA dynamoDB enhanced client putItem class cast exception
[英]Working with DynamoDB's PutItem ConditionExpression in Java (avoid replacement of attributes)
我有一個不包含任何唯一鍵(主鍵)的數據集。 僅當所有行組合在一起時,它才是唯一的。 但是,我在鍵中給了第一個屬性(類類型),以便在dynamoDB中創建表,如下所示:
CreateTableRequest createTableRequest = new CreateTableRequest()
.withTableName(tableName)
.withKeySchema(newKeySchemaElement()
.withAttributeName("Class type")
.withKeyType(KeyType.HASH))
.withAttributeDefinitions(newAttributeDefinition().withAttributeName("Class type").withAttributeType(ScalarAttributeType.S))
...
...;
對於此數據集,PutItem不起作用,因為“類類型”不是唯一的,它會將一個屬性替換為另一個屬性。 我希望所有行都上傳到dynamoDB。 我的putItem如下所示:
Map<String, AttributeValue> item = newItem(col[0], col[1], col[2], col[3], titanic_col[4]);
PutItemRequest putItemRequest = new PutItemRequest(tableName, item).withConditionExpression("Class type = NULL");
// No error in the above line. But getting exception.
PutItemResult putItemResult = dynamoDB.putItem(putItemRequest);
我在條件表達式行上遇到的異常:
Caught an AmazonServiceException, which means your request made it to AWS, but was rejected with an error response for some reason.
Error Message: Invalid ConditionExpression: Syntax error; token: "type", near: "Class type =" (Service: AmazonDynamoDBv2; Status Code: 400; Error Code: ValidationException; Request ID: J51GM61PM4AE2HPD0DVMQ6TNU7VV4KQNSO5AEMVJF66Q9ASUAAJG)
HTTP Status Code: 400
AWS Error Code: ValidationException
Error Type: Client
我想知道語法是否正確。 如果不是,請提供正確的語法來解決此問題(避免替換屬性)。
聲明:本站的技術帖子網頁,遵循CC BY-SA 4.0協議,如果您需要轉載,請注明本站網址或者原文地址。任何問題請咨詢:yoyou2525@163.com.