<legend id='35Ufc'><style id='35Ufc'><dir id='35Ufc'><q id='35Ufc'></q></dir></style></legend>
        <bdo id='35Ufc'></bdo><ul id='35Ufc'></ul>
    1. <small id='35Ufc'></small><noframes id='35Ufc'>

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

      1. 用于条件保存的 DynamoDBMapper

        时间:2023-09-28

          <tfoot id='RmBHw'></tfoot>
        1. <small id='RmBHw'></small><noframes id='RmBHw'>

            <tbody id='RmBHw'></tbody>
              • <legend id='RmBHw'><style id='RmBHw'><dir id='RmBHw'><q id='RmBHw'></q></dir></style></legend>

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

                  本文介绍了用于条件保存的 DynamoDBMapper的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

                  问题描述

                  我正在使用 DynamoDBMapper,并且希望有条件地保存当且仅当 hashkey 和 range 键组合不存在时.我知道有一些方法可以使用 UUID 来减少发生冲突的可能性,但我想通过使用条件保存来保护自己.

                  I'm using DynamoDBMapper and would like to conditionally save if and only if the hashkey and range key combination does not exist. I know there are ways to use UUIDs to reduce the possibility of a collision but I would like to protect myself by using conditional saves.

                  我遇到了这篇文章 使用 DynamoDBSaveExpression 但是我无法指定条件是hashkey AND rangekey"不能存在.API 指定withConditionalOperator 方法,但我在课堂上看不到这个.我也在使用来自 here 的最新 aws java sdk.

                  I came across this article that uses DynamoDBSaveExpression however I'm not able to specify that the condition is "hashkey AND rangekey" cannot exist. The API specifies a withConditionalOperator method but I'm not able to see this in my class. I am using the latest aws java sdk also from here.

                  关于如何有条件地保存的任何建议?或者我可能做错了什么?

                  Any suggestions on how to conditionally save? Or what I may be doing incorrectly?

                  推荐答案

                  DynamoDBSaveExpression saveExpression = new DynamoDBSaveExpression();
                  Map<String, ExpectedAttributeValue> expectedAttributes = 
                      ImmutableMap.<String, ExpectedAttributeValue>builder()
                          .put("hashKey", new ExpectedAttributeValue(false))
                          .put("rangeKey", new ExpectedAttributeValue(false))
                          .build();
                  saveExpression.setExpected(expectedAttributes);
                  saveExpression.setConditionalOperator(ConditionalOperator.AND);
                  try {
                      dynamoDBMapper.save(objectToSave, saveExpression);
                  } catch (ConditionalCheckFailedException e) {
                      //Handle conditional check
                  }
                  

                  这使用 public ExpectedAttributeValue(Boolean exists) 构造函数,它只是在内部调用 setExists.

                  This uses the public ExpectedAttributeValue(Boolean exists) constructor, which just internally calls setExists.

                  这篇关于用于条件保存的 DynamoDBMapper的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持html5模板网!

                  上一篇:SpringBoot - BeanDefinitionOverrideException:无效的bean定义 下一篇:如何将新的键值对放入 DynamoDB 中的映射中?(爪哇

                  相关文章

                  最新文章

                  <tfoot id='HfOW6'></tfoot>

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

                      <bdo id='HfOW6'></bdo><ul id='HfOW6'></ul>

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

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