dynobase-icon
Dynobase

Batch Delete Using DynamoDB Mapper (Guide w/ Code Examples)

Rafal Wilinski

Provided by Rafal Wilinski

The DynamoDBMapper class, provided by the AWS SDK for Java, provides a convenient way to map your domain classes to the items in a DynamoDB table. One of the features of the DynamoDBMapper class is the ability to perform batch delete operations. You can use the DynamoDBMapper's batchDelete method to delete multiple items in a single request in Java.

import com.amazonaws.services.dynamodbv2.datamodeling.DynamoDBMapper; import com.amazonaws.services.dynamodbv2.datamodeling.DynamoDBMapperConfig; import com.amazonaws.services.dynamodbv2.datamodeling.DynamoDBScanExpression; public class BatchDeleteExample { public static void main(String[] args) { // Create a new DynamoDBMapper AmazonDynamoDB client = AmazonDynamoDBClientBuilder.standard().build(); DynamoDBMapper mapper = new DynamoDBMapper(client); // Define a scan expression to retrieve all items in the table DynamoDBScanExpression scanExpression = new DynamoDBScanExpression(); // Retrieve the items to delete List<Product> items = mapper.scan(Product.class, scanExpression); // Delete the items mapper.batchDelete(items, DynamoDBMapperConfig.DEFAULT); } }

Tired of AWS Console? Try Dynobase.

Try 7-day free trial. No credit card needed.

Product Features

Download
/
Changelog
/
Pricing
/
Member Portal
/
Privacy
/
EULA
/
Twitter
/
Affiliates & Influencers
© 2024 Dynobase
+
Better DynamoDB Experience.
Try Dynobase to accelerate your DynamoDB workflow. Start your 7-day free trial today.