1

Say my classes are structured as follows:

abstract class A {
}

class B extends A {
    String attOfB;
}

class C extends A {
    String attOfC;
}

Then, can my DynamoDB mapper class use A with DynamoDBTypeConvertedJson?

@DynamoDBTable(tableName="ddbTable")
class ddbTableRecord {

    @DynamoDBTypeConvertedJson
    @DynamoDBAttribute
    private A a; 
}

Would this work, and if so, is it the right way to go about this? If this won't work, should I define a custom DynamoDBTypeConverted converter for class A that uses instanceOf to figure out what specific class the object belongs to?

JM Gelilio
  • 3,482
  • 1
  • 11
  • 23
  • If are going to put this much effort into you Amazon DynamoDB code, I recommend that you use the API considered best practice. That is, move from Java V1 to Java V2 and use the Enchanced Client for mapping. More information here -- https://docs.aws.amazon.com/sdk-for-java/latest/developer-guide/examples-dynamodb-enhanced.html – smac2020 Jun 23 '22 at 14:12

0 Answers0