-
Notifications
You must be signed in to change notification settings - Fork 964
Closed
Labels
bugThis issue is a bug.This issue is a bug.closed-for-stalenessdynamodb-enhancedp3This is a minor priority issueThis is a minor priority issue
Description
Describe the bug
I have a DynamoDbBean with a nested DynamoDbBean property.
I would like to update a single field in the inner bean without modifying any of the other properties in the outer bean record or its inner bean section. I'm unable to do this using an UpdateItemEnhancedRequest.
Despite using ignoreNulls(true) on my UpdateItemEnhancedRequest and @DynamoDbIgnoreNulls, I still see null fields in the inner bean NOT being ignored when the item is updated in the database.
Expected Behavior
Null fields in the inner bean should be ignored and only non-null fields should be updated.
Current Behavior
Null fields in the inner bean are NOT ignored and are written to the database.
Reproduction Steps
@DynamoDbBean
public class OuterBean {
private String Id;
private InnerBean innerBean;
public OuterBean() {
}
@DynamoDbPartitionKey
@DynamoDbAttribute(value = "Id")
public String getId() {
return Id;
}
public void setId(String Id) {
this.Id = Id;
}
@DynamoDbIgnoreNulls
@DynamoDbAttribute(value = "innerBean")
public InnerBean getInnerBean() {
return innerBean;
}
public void setInnerBean(@Nullable InnerBean innerBean) {
this.innerBean = innerBean;
}
}
@DynamoDbBean
public class InnerBean {
private Integer field1;
private Integer field2;
public Integer getField1() {
return field1;
}
public void setField1(Integer field1) {
this.field1 = field1;
}
public Integer getField2() {
return field2;
}
public void setField2(Integer field2) {
this.field2 = field2;
}
}
DynamoDbEnhancedClient client = DynamoDbEnhancedClient.builder()
.dynamoDbClient(
DynamoDbClient.builder()
.region(Region.of("us-east-1"))
.credentialsProvider(ProfileCredentialsProvider.create())
.build())
.build();
DynamoDbTable<OuterBean> table = client.table(caseTableName, TableSchema.fromBean(OuterBean.class));
OuterBean outerBean = new OuterBean();
outerBean.setId("1");
InnerBean innerBean = new InnerBean();
innearBean.setField1(1);
// Notice field2 is null
outerBean.setInnerBean(innerBean);
table.updateItem(
UpdateItemEnhancedRequest
.builder(OuterBean.class)
.item(outerBean)
.ignoreNulls(true)
.build()
);
Possible Solution
No response
Additional Information/Context
No response
AWS Java SDK version used
2.20.156
JDK version used
17
Operating System and version
Windows Server 2016 Standard Edition
Metadata
Metadata
Assignees
Labels
bugThis issue is a bug.This issue is a bug.closed-for-stalenessdynamodb-enhancedp3This is a minor priority issueThis is a minor priority issue