6
votes

I am developing a project in Java, and I am using the AWS SDK. I am using Dynamo DB. I am using the mapper, and it is very useful for me because I can perform basic operation directly on a java entity.

Recently, I have seen the library that allows to add transactionality to Dyanamo DB: https://github.com/awslabs/dynamodb-transactions

Such library works really fine, but it does not allow me to use the mapper. It only works with GetRequest, PutRequest, ...

I have no problem when getting results, because I can use the method "marshallIntoObject(Class, Map)" for obtaining the java entity from the results of a query.

How can I perform the same operation for saving/updating an item? I would really like to have a method that takes in input a java entity and converts it to a Map. I would use the returned map for performing query through the transaction engine. Is it available somewhere?

Moreover, are there any plans to make the project "dynamodb-transactions" able to support the mapper?

Thanks

3

3 Answers

10
votes

Following up on this: The linked feature request has now been implemented.

The DynamoDB transaction library now supports using the DynamoDB Mapper. Take a look at the examples and the javadocs to get started with it, and feel free to open questions in the github project if you have any.

0
votes

You could start by looking at how DynamoDB parses objects before saving. You can view DynamoDBMapper code on GitHub. You're should be looking for the protected class SaveObjectHandler implementations in the function save

Questions / Feature requests should be either logged at the issues section of the project on GitHub (There's one already for supporting DynamoDBMapper) or discussed in the AWS DynamoDB forum

0
votes

FYI - AWS launched DynamoDBMapper support for the built-in transactions API library (launched at re:Invent 2018): https://aws.amazon.com/about-aws/whats-new/2019/04/dynamodbmapper-now-supports-amazon-dynamodb-transactional-api-calls/