Creating a custom object for the DynamoDB table using the object persistence model in Java
Now, we are going to see how to create a custom object as an attribute while using the object persistence model.
Getting ready
To perform this recipe, you should have set up the project, as described in the earlier recipes, specifically pom.xml
, and also set up dependencies and the object model.
How to do it…
Sometimes, we need custom composite objects in order to represent our data models. Suppose that in our product table, we want to store the dimensions of the product; to do so, we can create the class of this type and use the DynamoDBMarshalling
annotation. While doing so, we also need to specify the converter in which we have to specify to read and write data.
Let's create a custom object for DynamoDB table:
Create the
custom
class by providing the attributes and getter setter method:public class Dimension { private int length; private int width; private int height; public int getLength() {...