DynamoDB Enhanced to support immutable Kotlin data classes
See original GitHub issueIn Kotlin your goal is to use data classes as immutable. With the current mapper this is not possible. You have to add an parameter less constructor to the class (noargs plugin) and all fields has to be changeable (var’s instead val’s)
Example:
data class Example(val name:String)
and not data class Example(var name:String)
Describe the Feature
The DynamoDB Enhanced mapper should call the constructor with all attributes read from the dynamodb.
Is your Feature Request related to a problem?
You can’t use immutable data classes and you have to use the norags plugin.
Describe alternatives you’ve considered
Use var’s instead of val’s and use norags plugin:
plugins{
id("org.jetbrains.kotlin.plugin.noarg") version "1.4.10"
}
noArg {
annotation("software.amazon.awssdk.enhanced.dynamodb.mapper.annotations.DynamoDbBean")
}
Your Environment
- AWS Java SDK version used: 2.15.7
- JDK version used: 11
- Operating System and version: Mac 10.15.7
Issue Analytics
- State:
- Created 3 years ago
- Reactions:34
- Comments:11 (2 by maintainers)
Top Results From Across the Web
Introducing immutable class mapping for the Enhanced ... - AWS
Step 1 : Annotate your existing immutable class. First, create and annotate an immutable class that will map to records in your DynamoDB...
Read more >AWS Java SDK V2. DynamoDB enhanced with Kotlin
Define the Data Class That Represents the DynamoDB Item. At the very basic level, the DynamoDB Enhanced Client library provides the following ...
Read more >DynamoDbImmutable (AWS SDK for Java - 2.18.33)
Class level annotation that identifies this class as being a DynamoDb mappable entity. Any class used to initialize a ImmutableTableSchema must have this ......
Read more >DynamoDB Enhanced Client for Java: Missing Setters Cause ...
The AWS SDK v2 for Java's DynamoDB Enhanced Client requires setters for every ... DynamoDbSortKey; @DynamoDbBean @Data public class Customer ...
Read more >Copy most attributes from one class object to another class
Also, all the fields are mutable and nullable. I had to make it this way because it's supposed to be a mapper class...
Read more >
Top Related Medium Post
No results found
Top Related StackOverflow Question
No results found
Troubleshoot Live Code
Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start Free
Top Related Reddit Thread
No results found
Top Related Hackernoon Post
No results found
Top Related Tweet
No results found
Top Related Dev.to Post
No results found
Top Related Hashnode Post
No results found
The builder’s set methods are supposed to return a builder instance. kotlin generated setters that return void.
The following works for me, but is quite tedious to write:
I made a plugin that allows you to use a data class directly with the
DataClassTableSchema
; might be worth checking out. https://github.com/oharaandrew314/dynamodb-kotlin-module