javaspring-bootamazon-dynamodbcrud-repository

Trying to update an attribute that was saved with null value with another value in a DynamoDB table using CrudRepository


I've saved an object in DynamoDB using SpringBoot CrudRepository. It has some attributes with null value ("myAttribute": null) and others with values ("otherAttribute": "aValue").

I have a method to update the object, where I search by id, update it and then, save it again.

If I update an attribute that has a value, it gets updated. But If I put a value to the ones that has null, they don't get updated.

Any ideas?


Solution

  • DynamoDB handles null value as a distinct data type. So I'll make an assumption here that you are setting a string or object type to Null, in which case the Mapper (assumption) is not saving the value as it drops null values. If it's a string, one thing you can do is set the value to "NULL" for example.

    https://docs.aws.amazon.com/amazondynamodb/latest/APIReference/API_AttributeValue.html