我试图从dynamodb代表年份(保留关键字)获取记录。
但无法取得成功。
DynamoDBScanExpression queryExpression = new DynamoDBScanExpression();
queryExpression.withFilterExpression("year = :year).withExpressionAttributeValues(valueMap);
result = dynamoDBTemplate.scan(ABC.class, queryExpression);
答案 0 :(得分:6)
DynamoDBScanExpression queryExpression = new DynamoDBScanExpression();
Map<String, AttributeValue> valueMap = new HashMap<>();
valueMap.put(":year", new AttributeValue().withS(2016));
queryExpression.withFilterExpression("#y = :year).
.withExpressionAttributeValues(valueMap);
Map<String, String> expression = new HashMap<>();
expression.put("#y", "year");
queryExpression.withExpressionAttributeNames(expression);
解决了我的问题。
答案 1 :(得分:0)
Map<String, String> rwnm = new HashMap();
rwnm.put("#a", "action");
QuerySpec querySpec = new QuerySpec();
querySpec.withFilterExpression("#a > :action");
querySpec.withNameMap(rwnm);
querySpec.withValueMap(new ValueMap().withString(":action", "LightsOn"));