Skip to content

Instantly share code, notes, and snippets.

@richardgrantserverless
Created April 11, 2022 22:08
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save richardgrantserverless/b9be15dbb3a202b0ea10a19312aed994 to your computer and use it in GitHub Desktop.
Save richardgrantserverless/b9be15dbb3a202b0ea10a19312aed994 to your computer and use it in GitHub Desktop.
public Product get(String id) throws IOException {
Product product = null;
HashMap<String, AttributeValue> av = new HashMap<String, AttributeValue>();
av.put(":v1", new AttributeValue().withS(id));
DynamoDBQueryExpression<Product> queryExp = new DynamoDBQueryExpression<Product>()
.withKeyConditionExpression("id = :v1")
.withExpressionAttributeValues(av);
PaginatedQueryList<Product> result = this.mapper.query(Product.class, queryExp);
if (result.size() > 0) {
product = result.get(0);
logger.info("Products - get(): product - " + product.toString());
} else {
logger.info("Products - get(): product - Not Found.");
}
return product;
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment