Dynamo DB java 语法

Dynamo DB java syntax

以下 dynamo 数据库查询语法有什么区别:
我们以前用

QueryRequest queryRequest = new QueryRequest().withTableName(TABLE).withKeyConditions(keyConditions)....;

在最新的文档中我看到:

table.query("Id", replyId,
            null, ///RangeKeyCondition - not used in this example
            "PostedBy = :val", //FilterExpression

我们应该使用哪一个? 它是一种新语法吗?差异?
谢谢

不同的风格,相同的 DynamoDB API。 The new Document API was introduced in Oct 2014

.. the new Document API allows the direct use of plain old Java data types and has less boilerplate. In fact, the Dynamo Document API can be used to entirely subsume what you can do with the low level client (i.e. AmazonDynamoDBClient) but with a much cleaner programming model and less code.

我个人仍在使用 AmazonDynamoDBClient(您的第一个代码示例)

        @Bean
            public AmazonDynamoDB amazonDynamoDB() {

                String accesskey = "";
                String secretkey = "";
                //
                // creating dynamo client
                BasicAWSCredentials credentials = new BasicAWSCredentials(accesskey, secretkey);
                AmazonDynamoDB dynamo = new AmazonDynamoDBClient(credentials);
                dynamo.setRegion(Region.getRegion(Regions.US_WEST_2));
                return dynamo;
            }

            @Bean
            public DynamoDBMapper dynamoDBMapper() {
                return new DynamoDBMapper(amazonDynamoDB());
            }

            @Bean
            public DynamoDBTemplate dynamoDBTemplate() {
                return new DynamoDBTemplate(amazonDynamoDB());
            }

    Use DynamoDbMapper for scanning the data : 
    DynamoDBQueryExpression<T> query = new DynamoDBQueryExpression<>();
query.addExpressionAttributeNamesEntry("xyz", "abc");
            List<T> results = dynamoDBMapper.query(T.class, query);

修改您的查询,即可搜索数据。