How can I overwrite an item and replace all its attributes.
For eg., I have an item A, with following attributes
ItemA
AttrA = ValueA
AttrB = ValueB
now I want to update ItemA with the following attributes
ItemA(Updated)
AttrB = ValueB1
AttrC = ValueC
I am using the Java SDK. I don’t want to delete the item and then create it. Currently, I am using BatchPutAttributesRequest to re-create the item but surprisingly, it doesn’t delete the attributes that are not present in the updated item.
So I end up with the Item
ItemA
AttrA = ValueA
AttrB = ValueB1
AttrC = ValueC
BatchPutAttributesRequest request does not delete existing Attribute that you had not included in your request. You need to send an another request DeleteAttributesRequest to Amazon SimpleDB by specifying list of Attributes that you wish to delete. BatchPutAttributesRequest can only add new Attribute or can update existing value of an attribute.