Rya*_*iao 5 java amazon-dynamodb
我使用UPDATE_SKIP_NULL_ATTRIBUTES
as 配置创建映射器,以便我可以保存实体并跳过空属性。它确实有效。但是,当我调用batchSave时,它不起作用。
有谁知道问题所在吗?
```
DynamoDBMapperConfig update_config = DynamoDBMapperConfig.builder()
.withSaveBehavior(DynamoDBMapperConfig.SaveBehavior.UPDATE_SKIP_NULL_ATTRIBUTES)
.build();
mapper = new DynamoDBMapper(client, update_config);
List<DynamoDBMapper.FailedBatch> failedBatches = mapper.batchSave(one, two);
```
Run Code Online (Sandbox Code Playgroud)
最后,我发现空属性已更新到我不想更新的数据库。我只想保存不为空值的属性。
嗯,我读了DynamoDBMapper的文档,发现它确实不支持 batch-save-skip-null-attributes
.
这是链接: batchSave
原因是:
config - Only DynamoDBMapperConfig.getTableNameOverride() and DynamoDBMapperConfig.getBatchWriteRetryStrategy() are considered. If TableNameOverride is specified, all objects in the two parameter lists will be considered to belong to the given table override. In particular, this method always acts as if **SaveBehavior.CLOBBER** was specified *regardless* of the value of the config parameter.
所以,我不知道如何只更新多个实体的一个字段。我必须通过PK获得所有,然后保存它们。
归档时间: |
|
查看次数: |
3634 次 |
最近记录: |