Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

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

Closed
namral opened this issue Sep 22, 2017 · 3 comments
Closed

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

namral opened this issue Sep 22, 2017 · 3 comments

Comments

@namral
Copy link

namral commented Sep 22, 2017

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 ?

@kiiadi
Copy link
Contributor

kiiadi commented Sep 25, 2017

At present the DynamoDB Mapper has not been fully ported to the v2 code-base. We do have a tracking issue for this: #35

@kiiadi kiiadi closed this as completed Sep 25, 2017
@namral
Copy link
Author

namral commented Sep 25, 2017

Good to know. I mistakenly opened it under the v2 version. It was mean't for v1

@biniama
Copy link

biniama commented Nov 1, 2018

@DynamoDBTypeConverted(converter = MetadataTypeConverter.class)

Is MetadataTypeConverter.class your custom implementation?

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

3 participants