Warning: file_get_contents(/data/phpspider/zhask/data//catemap/1/amazon-web-services/14.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181

Warning: file_get_contents(/data/phpspider/zhask/data//catemap/9/solr/3.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181
Java DynamoDBMappingException:哈希键没有映射_Java_Amazon Web Services_Amazon Dynamodb - Fatal编程技术网

Java DynamoDBMappingException:哈希键没有映射

Java DynamoDBMappingException:哈希键没有映射,java,amazon-web-services,amazon-dynamodb,Java,Amazon Web Services,Amazon Dynamodb,在编写DynamoDB Java应用程序时,如果表及其数据模型配置不正确,则在从表中写入或检索时,您可能会收到“哈希键无映射”错误。完全例外情况类似于: com.amazonaws.services.dynamodbv2.datamodeling.DynamoDBMappingException:;没有哈希键的映射这里有两件有用的事情需要检查: 1) 对于散列键值的主设置器,请确保正确设置了@DynamoDBHashKey符号@DynamoDBAttribute不是用于表主哈希键的正确属性,@d

在编写DynamoDB Java应用程序时,如果表及其数据模型配置不正确,则在从表中写入或检索时,您可能会收到“哈希键无映射”错误。完全例外情况类似于:


com.amazonaws.services.dynamodbv2.datamodeling.DynamoDBMappingException:;没有哈希键的映射

这里有两件有用的事情需要检查:

1) 对于散列键值的主设置器,请确保正确设置了
@DynamoDBHashKey
符号
@DynamoDBAttribute
不是用于表主哈希键的正确属性,
@dynamodbindeuthskey
也不是

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

        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
,表示字符串


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

请确保已声明带注释的映射类的getter为public

谢谢!非常感谢。非常感谢。如果我在一个抽象类中有HashKey属性,并且最终的数据结构继承了该属性,该怎么办?我也犯了同样的错误。如何解决。