High-level changes in mapping libraries from version 1 to version 2 of the SDK for Java - Amazon SDK for Java 2.x
Services or capabilities described in Amazon Web Services documentation might vary by Region. To see the differences applicable to the China Regions, see Getting Started with Amazon Web Services in China (PDF).

High-level changes in mapping libraries from version 1 to version 2 of the SDK for Java

The names of the mapping client in each library differ in V1 and V2:

  • V1 - DynamoDBMapper

  • V2 - DynamoDB Enhanced Client

You interact with the two libraries in much the same way: you instantiate a mapper/client and then supply a Java POJO to APIs that read and write these items to DynamoDB tables. Both libraries also offer annotations for the class of the POJO to direct how the client handles the POJO.

Notable differences when you move to V2 include:

  • V2 and V1 use different method names for the low-level DynamoDB operations. For example:

    V1 V2
    load getItem
    save putItem
    batchLoad batchGetItem
  • V2 offers multiple ways to define table schemas and map POJOs to tables. You can choose from the use of annotations or a schema generated from code using a builder. V2 also offers mutable and immutable versions of schemas.

  • With V2, you specifically create the table schema as one of the first steps, whereas in V1, the table schema is inferred from the annotated class as needed.

  • V2 includes the Document API client in the enhanced client API, whereas V1 uses a separate API.

  • All APIs are available in synchronous and asynchronous versions in V2.

See the DynamoDB mapping section in this guide for more detailed information on the V2 enhanced client.

Import dependency differences

V1 V2
<dependencyManagement> <dependencies> <dependency> <groupId>com.amazonaws</groupId> <artifactId>aws-java-sdk-bom</artifactId> <version>1.X.X</version> <type>pom</type> <scope>import</scope> </dependency> </dependencies> </dependencyManagement> <dependencies> <dependency> <groupId>com.amazonaws</groupId> <artifactId>aws-java-sdk-dynamodb</artifactId> </dependency> </dependencies>
<dependencyManagement> <dependencies> <dependency> <groupId>software.amazon.awssdk</groupId> <artifactId>bom</artifactId> <version>2.X.X*</version> <type>pom</type> <scope>import</scope> </dependency> </dependencies> </dependencyManagement> <dependencies> <dependency> <groupId>software.amazon.awssdk</groupId> <artifactId>dynamodb-enhanced</artifactId> </dependency> </dependencies>

* Latest version.

In V1, a single dependency includes both the low-level DynamoDB API and the mapping/document API, whereas in V2, you use the dynamodb-enhanced artifact dependency to access the mapping/document API. The dynamodb-enhanced module contains a transitive dependency on the low-level dynamodb module.