繁体   English   中英

DynamoDB 表达式未返回所有属性

[英]DynamoDB expression not returning all the attributes

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

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 和 Skill,即使语言环境也存在。 我想返回上面结构中的所有属性

我在这里缺少什么?

也许添加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

暂无
暂无

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM