Marshall DynamoDBMapper object into Map of Attributes

Viewed 1897

DynamoDBMapper provides way to build the object from Map

JavaDoc: public T marshallIntoObject(Class clazz, Map itemAttributes, DynamoDBMapperConfig config)

Is there a function which does the opposite of above function? Something which takes DynamoDBMapper object as an input and vends out Map itemAttributes?

DynamoDBMapper.save() must be doing the same thing, but I don't want to duplicate the code.

Regards,

Swapnil

1 Answers

As you mentioned in the comments, you can use DynamoDBMapperTableModel's convert method to get a Map<String, AttributeValue>. To get a DynamoDBMapperTableModel, you can use DynamoDBMapper's getTableModel method. Then, you can use the Map<String, AttributeValue> in a transactional Put or PutRequest.

Related