• <tfoot id='zC4rQ'></tfoot>

    <small id='zC4rQ'></small><noframes id='zC4rQ'>

      <legend id='zC4rQ'><style id='zC4rQ'><dir id='zC4rQ'><q id='zC4rQ'></q></dir></style></legend>

          <bdo id='zC4rQ'></bdo><ul id='zC4rQ'></ul>
        <i id='zC4rQ'><tr id='zC4rQ'><dt id='zC4rQ'><q id='zC4rQ'><span id='zC4rQ'><b id='zC4rQ'><form id='zC4rQ'><ins id='zC4rQ'></ins><ul id='zC4rQ'></ul><sub id='zC4rQ'></sub></form><legend id='zC4rQ'></legend><bdo id='zC4rQ'><pre id='zC4rQ'><center id='zC4rQ'></center></pre></bdo></b><th id='zC4rQ'></th></span></q></dt></tr></i><div id='zC4rQ'><tfoot id='zC4rQ'></tfoot><dl id='zC4rQ'><fieldset id='zC4rQ'></fieldset></dl></div>

        在 Java 中使用 DynamoDBMapper 更新 DynamoDB 项目

        时间:2023-09-29
        <legend id='aGH2H'><style id='aGH2H'><dir id='aGH2H'><q id='aGH2H'></q></dir></style></legend>
      1. <tfoot id='aGH2H'></tfoot>
      2. <small id='aGH2H'></small><noframes id='aGH2H'>

        • <i id='aGH2H'><tr id='aGH2H'><dt id='aGH2H'><q id='aGH2H'><span id='aGH2H'><b id='aGH2H'><form id='aGH2H'><ins id='aGH2H'></ins><ul id='aGH2H'></ul><sub id='aGH2H'></sub></form><legend id='aGH2H'></legend><bdo id='aGH2H'><pre id='aGH2H'><center id='aGH2H'></center></pre></bdo></b><th id='aGH2H'></th></span></q></dt></tr></i><div id='aGH2H'><tfoot id='aGH2H'></tfoot><dl id='aGH2H'><fieldset id='aGH2H'></fieldset></dl></div>

              <tbody id='aGH2H'></tbody>
              <bdo id='aGH2H'></bdo><ul id='aGH2H'></ul>

                  本文介绍了在 Java 中使用 DynamoDBMapper 更新 DynamoDB 项目的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

                  问题描述

                  如何使用 DynamoDBMapper 更新 DynamoDB 项目?

                  How can I update DynamoDB item using DynamoDBMapper?

                  我有多个进程,使用 DynamoDB 表,因此,get + save 会造成不一致.我找不到使用 DynamoDBMapper 更新项目的方法.

                  I have multiple processes, using the DynamoDB table, thus, get + save will create inconsistency. I can not find the method to update the item using DynamoDBMapper.

                  推荐答案

                  save()方法会执行putItemupdateItem 基于 SaveBehavior 中设置的值.请参考以下说明.由于这个原因,DynamoDBMapper 类中没有更新方法.但是,有一个单独的删除方法可用.

                  The save() method will perform the putItem or updateItem based on the value set in SaveBehavior. Please refer the below description. There is no update method in DynamoDBMapper class because of this reason. However, there is a separate delete method available.

                  在 DynamoDB 中保存项目.使用的服务方法由DynamoDBMapperConfig.getSaveBehavior() 值,使用任一AmazonDynamoDB.putItem(PutItemRequest) 或AmazonDynamoDB.updateItem(UpdateItemRequest):

                  Saves an item in DynamoDB. The service method used is determined by the DynamoDBMapperConfig.getSaveBehavior() value, to use either AmazonDynamoDB.putItem(PutItemRequest) or AmazonDynamoDB.updateItem(UpdateItemRequest):

                  更新(默认):UPDATE 不会影响保存操作和建模属性的 null 值会将其从该项目中删除动态数据库.由于 updateItem 请求的限制,当只有键时,UPDATE 的实现将发送 putItem 请求对象正在被保存,如果它会发送另一个 updateItem 请求给定的键已经存在于表中.

                  UPDATE (default) : UPDATE will not affect unmodeled attributes on a save operation and a null value for the modeled attribute will remove it from that item in DynamoDB. Because of the limitation of updateItem request, the implementation of UPDATE will send a putItem request when a key-only object is being saved, and it will send another updateItem request if the given key(s) already exists in the table.

                  UPDATE_SKIP_NULL_ATTRIBUTES : 与 UPDATE 类似,只是它忽略任何空值属性,并且不会将它们从该项目中删除动态数据库.它还保证只发送一个 updateItem请求,无论对象是否仅键.

                  UPDATE_SKIP_NULL_ATTRIBUTES : Similar to UPDATE except that it ignores any null value attribute(s) and will NOT remove them from that item in DynamoDB. It also guarantees to send only one single updateItem request, no matter the object is key-only or not.

                  CLOBBER: CLOBBER将清除并替换所有属性,包括未建模的属性,(删除并重新创建)保存.版本化的字段约束也将被忽视.saveExpression 参数中指定的任何选项由于版本化属性,将覆盖在任何约束上.

                  CLOBBER : CLOBBER will clear and replace all attributes, included unmodeled ones, (delete and recreate) on save. Versioned field constraints will also be disregarded. Any options specified in the saveExpression parameter will be overlaid on any constraints due to versioned attributes.

                  用法示例:-

                  DynamoDBMapperConfig dynamoDBMapperConfig = new DynamoDBMapperConfig(SaveBehavior.UPDATE);
                  

                  更新 DynamoDBMapperConfig (aws sdk 1.11.473) 构造函数似乎已被弃用,应该改用构建器:

                  UPDATE DynamoDBMapperConfig (aws sdk 1.11.473) constructor seems to be deprecated and the builder should be used instead:

                  DynamoDBMapperConfig dynamoDBMapperConfig = new DynamoDBMapperConfig.Builder()
                    .withConsistentReads(DynamoDBMapperConfig.ConsistentReads.CONSISTENT)
                    .withSaveBehavior(DynamoDBMapperConfig.SaveBehavior.UPDATE)
                    .build();
                  dynamoDBMapper.save(yourObject, dynamoDBMapperConfig);
                  

                  这篇关于在 Java 中使用 DynamoDBMapper 更新 DynamoDB 项目的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持html5模板网!

                  上一篇:Dynamodb:删除是否计入读取或写入容量? 下一篇:如何在我的 Lucene 应用程序中使用 ASCIIFoldingFilt

                  相关文章

                  最新文章

                  <i id='rYpZo'><tr id='rYpZo'><dt id='rYpZo'><q id='rYpZo'><span id='rYpZo'><b id='rYpZo'><form id='rYpZo'><ins id='rYpZo'></ins><ul id='rYpZo'></ul><sub id='rYpZo'></sub></form><legend id='rYpZo'></legend><bdo id='rYpZo'><pre id='rYpZo'><center id='rYpZo'></center></pre></bdo></b><th id='rYpZo'></th></span></q></dt></tr></i><div id='rYpZo'><tfoot id='rYpZo'></tfoot><dl id='rYpZo'><fieldset id='rYpZo'></fieldset></dl></div>
                  1. <legend id='rYpZo'><style id='rYpZo'><dir id='rYpZo'><q id='rYpZo'></q></dir></style></legend>
                    • <bdo id='rYpZo'></bdo><ul id='rYpZo'></ul>

                    1. <small id='rYpZo'></small><noframes id='rYpZo'>

                      <tfoot id='rYpZo'></tfoot>