Mohammad Tanvir
Mohammad Tanvir

Reputation: 11

DynamoDBMapper Maps support (java)

I am trying to write a map using com.amazonaws.services.dynamodb.datamodeling.DynamoDBMapper.save() and am getting this error:

Exception in thread "main" 
com.amazonaws.services.dynamodb.datamodeling.DynamoDBMappingException: 
Unsupported type: interface java.util.Map for public java.util.Map Config.getAttributes()

Is Map not supported by DynamoDBMapper?

Upvotes: 1

Views: 1416

Answers (1)

James
James

Reputation: 11

Create a HashMapMarshaller

public class HashMapMarshaller extends JsonMarshaller<HashMap<String, String>> 

{
    @Override
    public String marshall(HashMap<String, String> obj) {
        return super.marshall(obj);
    }

    @Override
    public HashMap<String, String> unmarshall(Class<HashMap<String, String>> clazz, String json) {
        return super.unmarshall(clazz, json);
    }
}

And then assign it to your property

@DynamoDBMarshalling(marshallerClass=HashMapMarshaller.class)

Upvotes: 1

Related Questions