Closed
Description
Describe the bug
As say, I have a order class:
@DynamoDbBean
public class Order {
private Long id;
private Integer amount;
public Order() {
}
public Order(long l, int i) {
this.id = l;
this.amount = i;
}
@DynamoDbPartitionKey
public Long getId() {
return id;
}
public void setId(Long id) {
this.id = id;
}
public Integer getAmount() {
return amount;
}
public void setAmount(int amount) {
this.amount = amount;
}
}
In this class, I use int other than Integer as the parameter of setAmount, strangely, when I try to retrieve the order I put before , the value of amount is null.
class OrderRepositoryTest {
@Autowired
DynamoDbEnhancedClient enhancedClient;
@Test
void findById() {
DynamoDbTable<Order> table = enhancedClient.table("order", TableSchema.fromBean(Order.class));
try {
table.createTable();
}
catch (Exception e){System.out.println(e.getMessage());}
table.putItem(new Order(1L, 10));
var order = table.getItem(Key.builder().partitionValue(1L).build());
assertThat(order.getAmount()).isEqualTo(10);
}
}
Is that a bug?
Expected Behavior
I think even use primitive type as the parameter, it should work, or throw an exception.
Current Behavior
It don't call the setAmount method.
Reproduction Steps
See the code.
Possible Solution
I think even use primitive type as the parameter, it should work, or throw an exception.
Additional Information/Context
No response
AWS Java SDK version used
2.17.201
JDK version used
18
Operating System and version
macOS Monterey 12.4
Metadata
Metadata
Assignees
Type
Projects
Milestone
Relationships
Development
No branches or pull requests
Activity
monika-sivamoorthy commentedon Jul 18, 2022
Can I work on this bug?
debora-ito commentedon May 16, 2023
@mikeyan123 apologies for the delay.
Our recommendation is to use non-primitive Java data types only.
Could not find this recommendation in the DynamoDB Enhanced Client documentation, so I'm marking this as a task to improve our docs.
debora-ito commentedon Aug 2, 2024
This is now addressed in the "Learn the basics of the DynamoDB Enhanced Client API" documentation:
github-actions commentedon Aug 2, 2024
This issue is now closed. Comments on closed issues are hard for our team to see.
If you need more assistance, please open a new issue that references this one.
Merge pull request #3228 from aws/staging/52e7acc3-909d-418f-9589-da8…