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

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

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

      2. DynamoDBMappingException:没有 HASH 键的映射

        时间:2023-06-26

        <tfoot id='aqxaE'></tfoot>

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

      3. <legend id='aqxaE'><style id='aqxaE'><dir id='aqxaE'><q id='aqxaE'></q></dir></style></legend>

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

                  <tbody id='aqxaE'></tbody>
                  本文介绍了DynamoDBMappingException:没有 HASH 键的映射的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着跟版网的小编来一起学习吧!

                  问题描述

                  在编写 DynamoDB Java 应用程序时,如果未正确配置表及其数据模型,则在从表中写入或检索时,您可能会收到无 HASH 键映射"错误.完整的例外类似于:

                  When writing a DynamoDB Java App you can receive the 'no mapping for HASH key' error when writing or retrieving from a table if the table and its data model are not configured correctly. The full exception would be similar to:

                  com.amazonaws.services.dynamodbv2.datamodeling.DynamoDBMappingException: <YourClassNameHere>;HASH键没有映射

                  推荐答案

                  这里有两个有用的东西:

                  Two helpful things to check here:

                  1) 对于散列键值的主要设置器,请确保正确设置了 @DynamoDBHashKey 表示法.@DynamoDBAttribute 不是用于表的主哈希键的正确键,@DynamoDBIndexHashKey 也不是.

                  1) For your main setter for your hash key value make sure that the @DynamoDBHashKey notation is correctly set. @DynamoDBAttribute is NOT the correct one to use for your table's main hash key and neither is @DynamoDBIndexHashKey.

                  2) 确保在表定义中定义了哈希键:

                  2) Make sure that the hash key is defined in the table definition:

                          CreateTableRequest createTableRequest = new CreateTableRequest()
                                  .withTableName("testtable")
                                  .withKeySchema(
                                          new KeySchemaElement("id", KeyType.HASH)
                                  )
                                  .withProvisionedThroughput(new ProvisionedThroughput(1L, 1L))
                                  .withAttributeDefinitions(
                                          new AttributeDefinition("id", "S")
                                  );
                  
                          CreateTableResult result = amazonDynamoDB.createTable(createTableRequest);
                  

                  上面的表定义创建了一个表'testtable',其主索引或散列键变量标题为id,类型为S,表示字符串.

                  The above table definition creates a table 'testtable' with a main index or hash key variable titled id and the type is S for string.

                  此外,如果您使用继承,请确保您没有两个同名的函数相互覆盖.Dynamo 将使用顶级 getter,这可能会导致问题.

                  Additionally, if you are using inheritance, make sure that you don't have two functions with the same name that override each other. Dynamo will use the top-level getter and this can cause issues.

                  这篇关于DynamoDBMappingException:没有 HASH 键的映射的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持跟版网!

                  上一篇:DynamoDB:如何创建具有嵌套 JSON 结构的表? 下一篇:具有 DynamoDB 和 MySQL 双数据源的 Spring Data/JPA 存储库

                  相关文章

                  • <bdo id='20ykM'></bdo><ul id='20ykM'></ul>
                  1. <small id='20ykM'></small><noframes id='20ykM'>

                    1. <tfoot id='20ykM'></tfoot>
                      <legend id='20ykM'><style id='20ykM'><dir id='20ykM'><q id='20ykM'></q></dir></style></legend>

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