Skip to content

Support AutoGeneratedTimestamp and UpdateBehavior annotation in nested objects #6109

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Open
wants to merge 1 commit into
base: master
Choose a base branch
from

Conversation

roamariei
Copy link
Contributor

@roamariei roamariei commented May 15, 2025

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

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

Checklist

  • I have read the CONTRIBUTING document
  • Local run of mvn install succeeds
  • 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
  • I have added tests to cover my changes
  • All new and existing tests passed
  • 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

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

Test Coverage Checklist

Scenario Done Comments if Not Done
1. Different TableSchema Creation Methods
a. TableSchema.fromBean(Customer.class) [ ]
b. TableSchema.fromImmutableClass(Customer.class) for immutable classes [ ]
c. TableSchema.documentSchemaBuilder().build() [ ]
d. StaticTableSchema.builder(Customer.class) [ ]
2. Nesting of Different TableSchema Types
a. @DynamoDbBean with nested @DynamoDbBean as NonNull [x]
b. @DynamoDbBean with nested @DynamoDbImmutable as NonNull [ ]
c. @DynamoDbImmutable with nested @DynamoDbBean as NonNull [ ]
d. @DynamoDbBean with nested @DynamoDbBean as Null [x]
e. @DynamoDbBean with nested @DynamoDbImmutable as Null [ ]
f. @DynamoDbImmutable with nested @DynamoDbBean as Null [ ]
3. CRUD Operations
a. scan() [ ]
b. query() [ ]
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 [ ]
c. maps with null values [ ]
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 [ ]

@roamariei roamariei requested a review from a team as a code owner May 15, 2025 09:50
@roamariei roamariei force-pushed the feature/support-autoGeneratedTimestamp-and-updateBehavior-annotations-in-nested-objects branch 2 times, most recently from 66731de to e719423 Compare May 21, 2025 13:47
…oDbUpdateBehavior on attributes within nested objects
@roamariei roamariei force-pushed the feature/support-autoGeneratedTimestamp-and-updateBehavior-annotations-in-nested-objects branch from eed3945 to e2225c5 Compare May 21, 2025 14:29
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

1 participant