aws-sdk-java icon indicating copy to clipboard operation
aws-sdk-java copied to clipboard

How to push `Map` type attribute to dynamodb table with map schema?

Open dieend opened this issue 11 years ago • 6 comments

This might be related to #331, but I can't find way for my own case.

Suppose I have this POJO class:

@DynamoDBTable
class Item {
    @DynamoDBHashKey
    private String id;
    @DynamoDBAttribute(attributeName="attr")
    private Map<String, String> attributes;
}

How to save it correctly using DynamoDBMapper? I've tried to explicitly config dynamo db using ConversionSchemas.V2 to no avail.

DynamoDBMapper mapper = new DynamoDBMapper(dynamodb, new DynamoDBMapperConfig(ConversionSchemas.V2));

I'm using aws-java-sdk-dynamodb with aws-java-sdk-bom version 1.10.18.

dieend avatar Sep 29 '15 04:09 dieend

Hm, that should work just fine with either ConversionSchemas.V2 or the default ConversionSchemas.V2_COMPATIBLE. What problem are you seeing?

fernomac avatar Sep 29 '15 16:09 fernomac

When I did mapper.save(model), I expect in dynamodb have attr column. But I'm not seeing it. Ah, is it possible because of I am using dynamodb local? Let me test it in aws dynamodb first.

dieend avatar Sep 30 '15 01:09 dieend

Any updates on this ?

manikandanrs avatar Nov 27 '15 21:11 manikandanrs

Yes, there is no problem, it's my side error where I set up the test wrongly. You can close this issue. Thanks.

Adinata

Typed in mobile, expect typi and auto corrected error. On Nov 28, 2015 4:04 AM, "Manikandan Subramanian" [email protected] wrote:

Any updates on this ?

— Reply to this email directly or view it on GitHub https://github.com/aws/aws-sdk-java/issues/520#issuecomment-160203358.

dieend avatar Nov 28 '15 00:11 dieend

Thanks for the update.

manikandanrs avatar Nov 28 '15 00:11 manikandanrs

I got the same problem and was stuck for hours - the mistake I had made was ... one of the test code was putting a blank string in the map - due to which it was breaking while reading the same map variable.

mac10046 avatar Oct 31 '17 12:10 mac10046