dynobase-icon
Dynobase

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

Rafal Wilinski

Provided by Rafal Wilinski

Last updated: October 23rd, 2026

BatchWriteItem cannot update attributes. Send an UpdateItem request for each complete key, or use TransactWriteItems when the changes must succeed or fail together.

DynamoDBMapper belongs to AWS SDK for Java 1.x and cannot be constructed with a 2.x DynamoDbClient. The example below shows the SDK 2.x low-level equivalent. For mapped domain objects, use the DynamoDB Enhanced Client.

This example uses Java 17+ and the software.amazon.awssdk:dynamodb SDK 2.x dependency. Configure an AWS Region and credentials through your usual AWS profile or runtime role. The Orders table has String keys pk and sk; adapt the table and keys to your schema.

import java.util.*; import software.amazon.awssdk.services.dynamodb.DynamoDbClient; import software.amazon.awssdk.services.dynamodb.model.*; public class Example { static AttributeValue s(String value) { return AttributeValue.builder().s(value).build(); } static Map<String, AttributeValue> key(String order) { return Map.of("pk", s("CUSTOMER#123"), "sk", s(order)); } public static void main(String[] args) throws InterruptedException { try (DynamoDbClient ddb = DynamoDbClient.create()) { for (String order : List.of("ORDER#001", "ORDER#002")) { ddb.updateItem(UpdateItemRequest.builder().tableName("Orders") .key(key(order)).updateExpression("SET #status = :status") .conditionExpression("attribute_exists(pk)") .expressionAttributeNames(Map.of("#status", "status")) .expressionAttributeValues(Map.of(":status", s("SHIPPED"))).build()); } } } }

The loop is not atomic: earlier updates remain committed if a later one fails. Record progress and choose retry behavior for the business operation.

Reference: AWS UpdateItem API. For related access patterns, see DynamoDB query examples.

Dynobase is a Professional GUI Client for DynamoDB

Start your 7-day free trial today

Product Features

Download
/
Pricing
/
Member Portal
/
Privacy
/
EULA
/
Twitter
© 2026 Dynobase
+
Still using AWS DynamoDB Console?
Try Dynobase to accelerate your DynamoDB workflow. Start your 7-day free trial today.