I have a Java POJO for writing into dynamodb. The DynamoDB is being updated by 2 different AWS lambdas from 2 different AWS SQS. I am using dynamoDBMapper to save record into dynamodb. The mapper config looks like below
DynamoDBMapperConfig mapperConfig = DynamoDBMapperConfig.Builder().withSaveBehavior(DynamoDBMapperConfig.SaveBehavior.UPDATE_SKIP_NULL_ATTRIBUTES)
.build();
I am using UPDATE_SKIP_NULL_ATTRIBUTES
so that I don't have to provide all attributes while saving a record and the save() will not overwrite the existing record.
My POJO looks like
@Data
@NoArgsConstructor
@AllArgsConstructor
@Builder(toBuilder = true)
@DynamoDBTable(tableName = "OrderShipment")
public class Order {
@DynamoDBHashKey(attributeName = "id")
@NonNull
public String id;
@DynamoDBRangeKey(attributeName = "sortKey")
@NonNull
public String sortKey;
@DynamoDBAttribute(attributeName = "createdDate")
public long createdDate;
@DynamoDBAttribute(attributeName = "lastUpdated")
public long lastUpdated;
@DynamoDBAttribute(attributeName = "status")
public String status;
I am writing createdDate
from one lambda and lastUpdated,status
from second lambda using dynamodbMapper's save() API. To my surprise, the status field is not being overwritten, however createdDate and lastUpdated are being overwritten from the events and being set to 0. From my understanding UPDATE_SKIP_NULL_ATTRIBUTES
should update the record and not overwrite the existing attributes in the record and it's working expected for status
, but not for the long type. Am I missing something here?