Batch Write Using DynamoDB Mapper (Guide w/ Code Examples)
![Rafal Wilinski](https://pbs.twimg.com/profile_images/1390706809548197895/SVCKpLNE_400x400.png)
Provided by Rafal Wilinski
With the batch write operations, you can save multiple items to the DynamoDB table, by passing a list of items to the batchSave
method of the DynamoDBMapper class. This method can be used to save new items and update existing items, depending on the primary key values provided. You might use the DynamoDBMapper's batchSave
method to write multiple items in a single request in Java.
import com.amazonaws.services.dynamodbv2.datamodeling.DynamoDBMapper; import com.amazonaws.services.dynamodbv2.datamodeling.DynamoDBMapperConfig; public class BatchWriteExample { public static void main(String[] args) { // Create a new DynamoDBMapper AmazonDynamoDB client = AmazonDynamoDBClientBuilder.standard().build(); DynamoDBMapper mapper = new DynamoDBMapper(client); // Define a list of items to write List<Product> items = new ArrayList<>(); items.add(new Product("111", "Product 1", 10, 2)); items.add(new Product("222", "Product 2", 20, 4)); items.add(new Product("333", "Product 3", 30, 6)); // Write the items mapper.batchSave(items, DynamoDBMapperConfig.DEFAULT); } }
Similar Code Examples
- Batch Write Item in DynamoDB Using Java
- Batch Query in DynamoDB Using Java
- Batch Put Item in DynamoDB Using Java
- Query Index in DynamoDB Using Java
- GetItem in DynamoDB Using Java
- Batch Save Using DynamoDB Mapper
- Update Multiple Items in DynamoDB Using Java
- Get in DynamoDB Using Java
- Delete Expression in DynamoDB Using Java
- Insert in DynamoDB Using Java
- Batch Load Using DynamoDB Mapper
- Update Expression in DynamoDB Using Java
- Get Item Request in DynamoDB Using Java
- Conditional Update in DynamoDB Using Java
- Batch Delete Using DynamoDB Mapper
Better DynamoDB experience.
Try 7-day free trial. No credit card needed.
Product Features
DynamoDB Tools
DynamoDB Info
© 2024 Dynobase