Support AutoGeneratedTimestamp and UpdateBehavior annotation in nested objects #6109
+704
−140
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
Description
Added support for @DynamoDbAutoGeneratedTimestampAttribute and @DynamoDbUpdateBehavior on attributes within nested objects. The @DynamoDbUpdateBehavior annotation will only take effect for nested attributes when using IgnoreNullsMode.SCALAR_ONLY.
Motivation and Context
@DynamoDbUpdateBehavior and @DynamoDbAutoGeneratedTimestampAttribute to work on nested objects too.
Modifications
The AutoGeneratedTimestampRecordExtension has been enhanced to support detection of the timestamp annotation on nested objects. Depending on the operation and the IgnoreNullsMode setting, nested attributes may either be treated as complete maps or flattened using the NESTED_ATTR_UPDATE convention (handled in transformItemToMapForUpdateExpression within UpdateItemOperation). Both scenarios are now supported, and the same generated timestamp is applied consistently across top-level and nested fields.
In parallel, the handling of the IgnoreNullsMode parameter within update requests was reviewed. As a result, UpdateExpressionUtils has been updated to evaluate the @DynamoDbUpdateBehavior annotation only when IgnoreNullsMode.SCALAR_ONLY is used, targeting flattened nested attributes identified via NESTED_ATTR_UPDATE.
When applied to a list of nested objects, the annotation is not supported, as individual elements cannot be updated — the entire list is replaced during an update operation.
Testing
Existing tests were updated, and new tests were added to validate the extended functionality.
Screenshots (if appropriate)
Types of changes
Checklist
mvn install
succeedsscripts/new-change
script and following the instructions. Commit the new file created by the script in.changes/next-release
with your changes.License
Test Coverage Checklist