Use of DynamoDB annotations in nested objects

Viewed 1085

I am trying to use DynamoDB annotations in nested objects as below:

@DynamoDBTable(tableName=xyz)
class entity1{
    @DynamoDBAttribute
    @DynamoDBTypeConvertedJson
    private List<UserAction> userActions;
}

class UserAction{
    @DynamoDBAutoGeneratedKey
    private String actionId;

    @DynamoDBAttribute
    @DynamoDBAutoGeneratedTimestamp(strategy = DynamoDBAutoGenerateStrategy.CREATE)
    private Long createdTime;
}

I dont see the above attributes are auto generated in UserAction class. I would like to know if these annotation usages are supported in nested objects or not. Please suggest.

1 Answers

Add @DynamoDbDocument annotation on UserAction class. This annotation will ensure the instance of UserAction class is correctly serialized to a Dynamo DB sub-document before persisting in table.


@DynamoDbDocument
class UserAction{
    //...............
    //...............
}

Related