Update specific attributes with DynamoDBMapper in java

Viewed 3418

I want to update only the specific attributes of the item using DynamoDBMapper. For example, I have a User table with attributes viz., id, name, address.

@Data
@DynamoDBTable(tableName = "Users")
public class User {

    @DynamoDBHashKey
    @DynamoDBGeneratedUuid(DynamoDBAutoGenerateStrategy.CREATE)
    private String id;

    @DynamoDBAttribute
    private String name;

    @DynamoDBAttribute
    private Address address;

}

I want to update only the address attribute and not the other fields (selective update).

I could find a sample example by using UpdateItemSpec but couldn't find it for DynamoDBMapper. With UpdateItemSpec, I can use withUpdateExpression() to define update expression. More details can be found here.

Is there any way, to achieve the same with DynamoDBMapper?

1 Answers
Related