Database Reference
In-Depth Information
HashMap<String, KeysAndAttributes>();
// Create list of keys to fetched
ArrayList<Map<String, AttributeValue>> keys = new
ArrayList<Map<String, AttributeValue>>();
// Key 1
HashMap<String, AttributeValue> key1 = new HashMap<String,
AttributeValue>();
key1.put("bookId", new AttributeValue().withN("2001"));
keys.add(key1);
// key 2
HashMap<String, AttributeValue> key2 = new HashMap<String,
AttributeValue>();
key2.put("bookId", new AttributeValue().withN("2002"));
keys.add(key2);
requestItems.put("Book", new
KeysAndAttributes().withKeys(keys));
// Create Batch Get Item request
BatchGetItemRequest batchGetItemRequest = new
BatchGetItemRequest().withRequestItems(requestItems);
// invoke batch get items method
BatchGetItemResult batchGetItemResult =
dynamoDBClient.batchGetItem(batchGetItemRequest);
Batch write items
This API allows us to put or delete up to 25 items from multiple tables in one go, as
shown in the following code:
// Create a map for the requests
Map<String, List<WriteRequest>> writeRequestItems = new
HashMap<String, List<WriteRequest>>();
// Create put request and add new book item in it
Search WWH ::




Custom Search