Skip to content

@DynamoDBDocument not working for a Map<Object, Object> #1315

Closed
@namral

Description

@namral

I tried to use @DynamoDBDocument to serialize a POJO that looks like this :

`
@DynamoDBDocument
public class Metadata {
Map<Object, Object> metadata;

    public Metadata() {
    }

    public Metadata(Map<Object, Object> metadata) {
        this.metadata = metadata;
    }

    @DynamoDBAttribute
    public Map<Object, Object> getMetadata() {
        return stateMetadata;
    }

    public void setMetadata(Map<Object, Object> metadata) {
        this.metadata = metadata;
    }
}

@DynamoDBTable(tableName = "REPLACED_BY_CONFIG")
public class ProductItem {
private Metadata metadata;

     @DynamoDBAttribute
     public Metadata getMetadata() {
           return metadata;
     }

}
`

http://docs.aws.amazon.com/amazondynamodb/latest/developerguide/DynamoDBMapper.Annotations.html#DynamoDBMapper.Annotations.DynamoDBDocument

It throws the following exception :
Caused by: com.amazonaws.services.dynamodbv2.datamodeling.DynamoDBMappingException: not supported; requires @DynamoDBTyped or @DynamoDBTypeConverted

I was able to get this to work by adding the following annotation to the getter method in ProductItem
@DynamoDBTypeConverted(converter = MetadataTypeConverter.class)

I was wondering why I see this behavior ?

Metadata

Metadata

Assignees

No one assigned

    Labels

    guidanceQuestion that needs advice or information.

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions