gpt4 book ai didi

amazon-web-services - 由于命名约定,使用 DynamoDB AWS SDK [No Mapping for Hash Key] 时出错

转载 作者:行者123 更新时间:2023-12-05 05:21:30 26 4
gpt4 key购买 nike

在使用 AWS JAva SDK 时,我们使用 @DynamoDBHashKey 注释来定义 DynamoDBHashKey。

奇怪的是,如果我使用如下注释

@DynamoDBHashKey 
String Abc

代替

@DynamoDBHashKey 
String abc

this gives me an error, no mapping for HASH key [junit] at com.amazonaws.services.dynamodbv2.datamodeling.DynamoDBMapperTableModel.hashKey(DynamoDBMapperTableModel.java:119) [junit] at com.amazonaws.services.dynamodbv2.datamodeling.DynamoDBMapperTableModel$Builder.build(DynamoDBMapperTableModel.java:449) [junit] at com.amazonaws.services.dynamodbv2.datamodeling.StandardModelFactories$StandardTableFactory.getTable(StandardModelFactories.java:104) [junit] at com.amazonaws.services.dynamodbv2.datamodeling.DynamoDBMapper.getTableModel(DynamoDBMapper.java:393) [junit] at com.amazonaws.services.dynamodbv2.datamodeling.DynamoDBMapper.generateCreateTableRequest(DynamoDBMapper.java:2148) [junit] at com.amazonaws.services.dynamodbv2.datamodeling.AbstractDynamoDBMapper.generateCreateTableRequest(AbstractDynamoDBMapper.java:319)

我无法理解为什么变量命名约定在失败中起作用任何想法?

最佳答案

内省(introspection)魔法在这种情况下似乎不起作用。 Force the attribute name使用参数 attributeName

@DynamoDBTable(tableName="Books")
public static class Book {
private String Abc;

@DynamoDBHashKey(attributeName="Abc")
public int getAbc() {
return Abc;
}
}

关于amazon-web-services - 由于命名约定,使用 DynamoDB AWS SDK [No Mapping for Hash Key] 时出错,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/42802020/

26 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com