1

I am trying to scan a DynamoDB table that has lists of maps as attribute values.

DynamoDB table:

{
  "Name": "n",
  "Accounts": [
    {
      "address": "a",
      "name": "b"
    },
    {
      "address": "c",
      "name": "d"
    }
}

Target Java object:

@DynamoDbBean
public class Target {
 public String Name;
 public List<HashMap<String,String>> Accounts;

 //getters setters
   @DynamoDbPartitionKey
    public String getName() {
        return Name;
    }
}

I get the following error:

java.lang.IllegalStateException: Converter not found for EnhancedType(java.util.List<java.util.HashMap<java.lang.String, java.lang.String>>)

I know that this kind of nested structure is not supported out-ob-box so I need to provide a converter to tell how it can map DynmaoDB objects to my java class.

I have started to implement a StaticTableSchema however I couldn't get it how I can apply for my case:

      final StaticTableSchema<Target> build = StaticTableSchema.builder(TargetCompany.class).newItemSupplier(TargetCompany::new)
     .addAttribute(String.class, a ->a.name("Name").getter(TargetCompany::getName).setter(TargetCompany::setName))
.addAttribute(EnhancedType.listOf(EnhancedType.mapOf(String.class,String.class)), a->a.name("Accounts") ??????
.setter(TargetCompany::setAccounts)

There are also some converter interfaces that I can implement however at this point I am stuck. I am using Java SDK v2 so I usually find examples for v1 but still, they are just for primitive types not complex cases like mine.

Any idea how I can map my DynamoDB attribute value to my Java object?

Thanks

1
  • 4
    the v2 aws dynamo sdk is very poorly documented, I am also struggling for mapping custom objects using java annotations
    – Zoltan
    Commented Jun 8, 2022 at 20:25

0

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.