I am using the mapper provided by the AWS SDK, with Java. I need to update record on DynamoDB: is there any way, using the mapper, to avoid that a null property of a mapped entity is stored on DynamoDB, overwriting the old value?
I try to explain my question with an example. I have a java entity with three properties: id, a, b. It is mapped to a DynamoDB table with hashKey only, on field id. On DynamoDB it is stored a record {"id":"1", "a":"aa"}. After an update called on an entity with id:1, a:null and b:"bb", I find on DynamoDB a record {"id":"1", "b":"bb"}.
Any solutions?
Thanks
You will be very interested in the new SaveBehavior
strategy, recently introduced in v1.5.4. The new SaveBehavior
strategy is called UPDATE_SKIP_NULL_ATTRIBUTES
. This new SaveBehavior
is very similar to the existing UPDATE
strategy. The only difference is that any attributes sent with null values will not be removed from the item in DynamoDB. Here is the link to the JavaDoc.
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With