aws-sdk-java-v2 icon indicating copy to clipboard operation
aws-sdk-java-v2 copied to clipboard

DDBEnhanced - Support to flatten a Map into top level attributes of the object

Open anasatirbasa opened this issue 8 months ago • 0 comments

Added the facility of using an annotation that will flatten a map of attributes in a class, similar to what @DynamoDbFlatten does for attributes from another class.

Description

Added a new annotation named DynamoDbFlattenMap that can be applied at method level for only a single map of attributes within a class (Map<String, String>). If used on multiple maps of attributes, the serialization will throw an exception.

Motivation and Context

#2542

Modifications

Followed the same approach as for DybamoDbFlatten annotation, that is used to flatten all the attributes of a separate DynamoDb bean that is stored in the current bean

Testing

The changes have already been tested by running the existing tests and also added new unit/integration tests for the new flow.

Test Coverage Checklist

Scenario Done Comments if Not Done
1. Different TableSchema Creation Methods
a. TableSchema.fromBean(Customer.class) [x]
b. TableSchema.fromImmutableClass(Customer.class) for immutable classes [x]
c. TableSchema.documentSchemaBuilder().build() [ ]
d. StaticTableSchema.builder(Customer.class) [x]
2. Nesting of Different TableSchema Types
a. @DynamoDbBean with nested @DynamoDbBean as NonNull [x]
b. @DynamoDbBean with nested @DynamoDbImmutable as NonNull [x]
c. @DynamoDbImmutable with nested @DynamoDbBean as NonNull [x]
d. @DynamoDbBean with nested @DynamoDbBean as Null [x]
e. @DynamoDbBean with nested @DynamoDbImmutable as Null [x]
f. @DynamoDbImmutable with nested @DynamoDbBean as Null [x]
3. CRUD Operations
a. scan() [ ]
b. query() [x]
c. updateItem() [x]
d. putItem() [x]
e. getItem() [x]
f. deleteItem() [ ]
g. batchGetItem() [ ]
h. batchWriteItem() [ ]
i. transactGetItems() [ ]
j. transactWriteItems() [ ]
4. Data Types and Null Handling
a. top-level null attributes [x]
b. collections with null elements [x]
c. maps with null values [x]
d. conversion between null Java values and AttributeValue [ ]
e. full serialization/deserialization cycle with null values [ ]
5. AsyncTable and SyncTable
a. DynamoDbAsyncTable Testing [ ]
b. DynamoDbTable Testing [ ]
6. New/Modification in Extensions
a. Tables with Scenario in ScenarioSl No.1 (All table schemas are Must) [ ]
b. Test with Default Values in Annotations [ ]
c. Combination of Annotation and Builder passes extension [ ]
7. New/Modification in Converters
a. Tables with Scenario in ScenarioSl No.1 (All table schemas are Must) [ ]
b. Test with Default Values in Annotations [ ]
c. Test All Scenarios from 1 to 5 [ ]

Screenshots (if appropriate)

Types of changes

  • [ ] Bug fix (non-breaking change which fixes an issue)
  • [x] New feature (non-breaking change which adds functionality)

Checklist

  • [x] I have read the CONTRIBUTING document
  • [x] Local run of mvn install succeeds
  • [x] My code follows the code style of this project
  • [ ] My change requires a change to the Javadoc documentation
  • [ ] I have updated the Javadoc documentation accordingly
  • [x] I have added tests to cover my changes
  • [x] All new and existing tests passed
  • [x] I have added a changelog entry. Adding a new entry must be accomplished by running the scripts/new-change script and following the instructions. Commit the new file created by the script in .changes/next-release with your changes.
  • [ ] My change is to implement 1.11 parity feature and I have updated LaunchChangelog

License

  • [x] I confirm that this pull request can be released under the Apache 2 license

anasatirbasa avatar May 14 '25 07:05 anasatirbasa