For example, I have a table with userID as hash key. The same table contains commentID as range key. I want to find all entries related to a specific userID. Using java SDK, what is the most efficient way to retrieve all items that has a particular hash key.
SOLUTION
Here's how I did it:
QuerySpec spec = new QuerySpec()
.withKeyConditionExpression("userID = :v_id")
.withValueMap(new ValueMap()
.withString(":v_id", user.getId()));
ItemCollection<QueryOutcome> items = table.query(spec);
Iterator<Item> iterator = items.iterator();
Item item = null;
while (iterator.hasNext()) {
item = iterator.next();
System.out.println(item.toJSONPretty());
}