I am using Amazon's DynamoDB java SDK and want to know the difference between the AmazonDynamoDBClient and DynamoDB classes. I can't seem to find anything on them since there appears to be very little documentation. Is there any reason I should use one or the other? Are their any major benefits or drawbacks?
The Amazon DynamoDB enhanced client is a high-level library that is part of the AWS SDK for Java version 2 (v2). It offers a straightforward way to map client-side classes to DynamoDB tables. You define the relationships between tables and their corresponding model classes in your code.
The SDK for Java provides thread-safe clients for working with DynamoDB. As a best practice, your applications should create one client and reuse the client between threads.
DynamoDB lets you offload the administrative burdens of operating and scaling a distributed database, so that you don't have to worry about hardware provisioning, setup and configuration, replication, software patching, or cluster scaling.
The DynamoDBMapper class is the entry point to Amazon DynamoDB. It provides access to a DynamoDB endpoint and enables you to access your data in various tables. It also enables you to perform various create, read, update, and delete (CRUD) operations on items, and run queries and scans against tables.
This is a good question. It looks like DynamoDB
is a wrapper to the AmazonDynamoDBClient
, providing a different interface. So this may be obvious and not the answer you are looking for but let me describe some of the differences between them.
The createTable
method in AmazonDynamoDBClient
returns back a CreateTableResult
object, whereas the DynamoDB
's createTable method returns back a Table
object. This Table
object can then be used to do CRUD on that table. The Table
object starts looking like a generic ORM object for DynamoDB. So its not really DynamoDB
class vs AmazonDynamoDBClient
, its more like DynamoDB
& Table
classes vs AmazonDynamoDBClient
.
AmazonDynamoDBClient
is obviously older than the DynamoDB
class. DynamoDB
is pretty new, coming out in 1.9.x. But there is another class here worth mentioning, DynamoDBMapper
. DynamoDBMapper
allows for even more ORM like operations. Allowing developers to annotate their JavaBean data-model's so that they can easily be CRUD'd against a DynamoDB table. You get to work with your objects directly and the DynamoDBMapper
will do the CRUD work on the DynamoDB database. DynamoDBMapper
is older than the DynamoDB
class. I think maybe some developers did not want to work with the DynamoDBMapper
(maybe not a fan of OO or annotations?) and there needed to be another paradigm, but I'm only hypothesizing. So the DynamoDB
and Table
classes were created. With the Table
class you can interact with your tables more easily than the AmazonDynamoDBClient
but without the overhead of creating JavaBean data-models that the DynamoDBMapper
require.
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With