我正在对 DynamoDB 表执行扫描,然后我需要将返回的项目中的相应属性添加到类型列表中User
(User
具有单个构造函数User(String uuid)
)。该代码当前成功扫描了数据库并返回了一个List
扫描结果。但是,由于某种原因,我的迭代似乎返回 null。
AmazonDynamoDBClient client = dynamoClient.getDynamoClient();
DynamoDBMapper mapper = new DynamoDBMapper(client);
try {
DynamoDBScanExpression scanExpression = new DynamoDBScanExpression();
Map<String, Condition> scanFilter = new HashMap<String, Condition>();
Condition scanCondition =
new Condition().withComparisonOperator(ComparisonOperator.NOT_NULL);
scanFilter.put("uuid", scanCondition);
scanExpression.setScanFilter(scanFilter);
List scanResults = mapper.scan(UserAccounts.class, scanExpression);
for (Iterator it = scanResults.iterator(); it.hasNext();) {
//User user = (User) it.next();
allUserSummary.add(new User(scanResults.get(1).toString()));
}
} catch (Exception e) {
// TODO
}