DynamoDBTypeConvertedJson for an abstract class

454 Views Asked by At

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?

0

There are 0 best solutions below