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 |
---|---|
|
|
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.