DynamoDB Enhanced Client Polymorphic Types
- Dominant language
- Java
- Stars
- 2.6k
- Forks
- 1k
- Avg merge
- 2d 9h
- Merged PRs (30d)
- 51
Description
We should support reading/writing base types using the DynamoDB Enhanced Client.
Potential syntax/example (not yet implemented):
```java
@DynamoDbBean
@DynamoDbSubtypes({Employee.class, Customer.class})
public abstract class Person {
@DynamoDBHashKey
private long id;
private String name;
}
@DynamoDbBean
private class Employee extends Person {
}
@DynamoDbBean
private class Customer extends Person {
}
DynamoDbEnhancedClient client = DynamoDbEnhancedClient.create();
DynamoDbTable people = client.table("people", TableSchema.fromBean(Person.class));
Employee bob = new Employee();
bob.setId(1);
bob.setName("Bob the Builder");
Customer lfh = new Customer();
lfh.setId(2);
lfh.setName("Low Flying Hawk");
people.putItem(bob);
people.putItem(lfh);
assertThat(people.getItem(Key.builder().partitionValue(1).build())).isInstanceOf(Employee.class);
assertThat(people.getItem(Key.builder().partitionValue(2).build())).isInstanceOf(Customer.class);
```
Contributor guide
Assessment
This issue has not been assessed yet.