I'm new to DynamoDB and am having some trouble loading data from my database with my Java code. I can see from the DDB console that I'm successfully storing data in tables and reading it in through scan. But if I try to use load, things fail.
Here's what I'm doing:
I'd like to read all of the items in a table, so I use this code
DynamoDBScanExpression scanExpression = new DynamoDBScanExpression();
List<SericonNoSQLdbRecord> scanResult = dynamoMapper.scan(tableName2Class(tableName),
scanExpression);
for (SericonNoSQLdbRecord record : scanResult)
{
record.printJSON();
}
This works beautifully and each item is printed out. The fact that this works tells me that the underlying class that I'm storing is properly annotated.
Later on, I want to read a single item. For that I use this code
Object ob = dynamoMapper.load(tableName2Class(tableName),
primaryIndex); // this is the HashKey
When this code is executed I can see that the empty constructor for my class is called (as can be expected) followed by a call to set the HashKey. After that, I expect that setters for the attributes will be called but this doesn't happen. Instead, load simply returns null. I am catching errors, and none seem to be thrown.
I know that load returns null if no item is found. But the fact that my HashKey's setter is called suggests that something was found.
Any ideas on what could be going wrong here. Any ideas on how to further debug this problem?