Operations, requests and responses changes
In version 2 of the SDK for Java, requests are passed to a client operation. For example
DynamoDbClient's
PutItemRequest
is passed to DynamoDbClient.putItem
operation. These
operations return a response from the Amazon Web Services service, such as a
PutItemResponse
.
Version 2 of the SDK for Java has the following changes from version 1.
-
Operations with multiple response pages now have a
Paginator
method for automatically iterating over all items in the response. -
You cannot mutate requests and responses.
-
You must create requests and responses with a static builder method instead of a constructor. For example, version 1's
new PutItemRequest().withTableName(...)
is nowPutItemRequest.builder().tableName(...).build()
. -
Operations support a short-hand way to create requests:
dynamoDbClient.putItem(request -> request.tableName(...))
.
The following sections describe specific changes between version 1 and version 2. Some parameter type changes can be converted automatically using the migration tool, while other changes require manual updates to your code.