gpt4 book ai didi

java - DynamoDB 表达式未返回所有属性

转载 作者:行者123 更新时间:2023-12-03 07:41:01 25 4
gpt4 key购买 nike

使用以下命令获取扫描结果:

PaginatedScanList<Table> scanList =
dynamoDBMapper.scan(table.class, new DynamoDBScanExpression());

YAML

TableDDB:
Type: "AWS::DynamoDB::Table"
# Retain the DynamoDB table even if stack is deleted
UpdateReplacePolicy: Retain
DeletionPolicy: Retain
Properties:
AttributeDefinitions:
- AttributeName: "id"
AttributeType: "S"
- AttributeName: "skill"
AttributeType: "S"
- AttributeName: "locale"
AttributeType: "S"
KeySchema:
- AttributeName: "id"
KeyType: "HASH"
BillingMode: PAY_PER_REQUEST
TableName: "table"
GlobalSecondaryIndexes:
- IndexName: "skill-locale-index"
KeySchema:
- AttributeName: "skill"
KeyType: HASH
- AttributeName: "locale"
KeyType: RANGE
Projection:
ProjectionType: "ALL"

表记录如下

@Getter
@Setter
@ToString
@DynamoDBTable(tableName = "table")
public class Table {
@DynamoDBHashKey(attributeName = "id")
@NonNull
@DynamoDBAutoGeneratedKey
private String id;

@DynamoDBIndexHashKey(
attributeName = "skill",
globalSecondaryIndexName = "skill-locale-index")
private String skill;

@DynamoDBIndexRangeKey(
attributeName = "locale",
globalSecondaryIndexName = "skill-locale-index")
private String locale;
}

但是我得到的结果是所有条目中只有 id 和技能,即使语言环境也存在。我想返回上面结构中的所有属性

我在这里缺少什么?

最佳答案

也许添加 DynamoDBAttribute 的注释引用

@Getter
@Setter
@ToString
@DynamoDBTable(tableName = "table")
public class Table {
@DynamoDBHashKey(attributeName = "id")
@NonNull
@DynamoDBAutoGeneratedKey
private String id;

@DynamoDBIndexHashKey(
attributeName = "skill",
globalSecondaryIndexName = "skill-locale-index")
private String skill;

@DynamoDBIndexRangeKey(
attributeName = "locale",
globalSecondaryIndexName = "skill-locale-index")
@DynamoDBAttribute(attributeName = "locale")
private String locale;

}

更多信息在这里:https://docs.aws.amazon.com/amazondynamodb/latest/developerguide/DynamoDBMapper.Annotations.html#DynamoDBMapper.Annotations.DynamoDBAttribute

关于java - DynamoDB 表达式未返回所有属性,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/68347017/

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