DynamoDB Enhanced Client API support for Java records

1k Views Asked by At

I want to use a Java record type with the AWS DynamoDB Enhanced Client API in the AWS SDK for Java 2.x.. I've read Introducing immutable class mapping for the Enhanced DynamoDB Client in AWS SDK for Java 2.x and Working with immutable data classes, but as far as I can tell, not only do I have to completely spell out all the record getters (completely defeating the purpose of Java record types), I also have to implement a huge boilerplate Builder internal class.

Am I missing the instructions somewhere? I know that AWS Lambda has support for Java records in passing data. What about DynamoDB? Is there a way to use Java records in the DB Enhanced Client API?

1

There are 1 best solutions below

2
VonC On

Am I missing the instructions somewhere?

Apparently not: in the context of the AWS DynamoDB Enhanced Client API for Java 2.x, it appears that you're correct: the current documentation does not provide a clear path for using Java records directly with the Enhanced Client API.

As you noted, there is support for immutable data classes ,but the process requires spelling out the getters and implementing a Builder class.

You can see an example in aws/aws-sdk-java-v2 issue 3695: "Support optional prefix for @DynamoDbFlatten fields".
But nothing is implemented from that issue.