Amazon DynamoDB putItem 返回空值

Amazon DynamoDB putItem returning null

我正在使用 AmazonDynamoDBClient putItem 方法在数据库中插入项目。 return putItem 的类型是 PutItemResult 但我得到的是 null。

AmazonDynamoDBClient client = new AmazonDynamoDBClient();
PutItemRequest r = new PutItemRequest();
r.addItemEntry("custId",new Attribute Value("101"));
PutItemResult result = client.putItem(r);
//result is null

项目已成功插入数据库,但为什么结果为空?

请根据您的要求指定RETURN_VALUE。默认为 NONE.

ReturnValues — (String) Use ReturnValues if you want to get the item attributes as they appeared before they were updated with the PutItem request. For PutItem, the valid values are:

NONE - If ReturnValues is not specified, or if its value is NONE, then nothing is returned. (This setting is the default for ReturnValues.) ALL_OLD - If PutItem overwrote an attribute name-value pair, then the content of the old item is returned. Note: The ReturnValues parameter is used by several DynamoDB operations; however, PutItem does not recognize any values other than NONE or ALL_OLD.

来自 API 文档:-

public PutItemRequest(String tableName,
                      Map<String,AttributeValue> item,
                      String returnValues)

Set return values

The ReturnValues parameter is used by several DynamoDB operations; however, PutItem does not recognize any values other than NONE or ALL_OLD.

ALL_NEW、UPDATED_NEW 和 UPDATED_OLD 用于 UpdateItem 操作。

UPDATED_OLD - Returns only the updated attributes, as they appeared before the UpdateItem operation.

ALL_NEW - Returns all of the attributes of the item, as they appear after the UpdateItem operation.

UPDATED_NEW - Returns only the updated attributes, as they appear after the UpdateItem operation.