Skip to content

DynamoDB Enhanced Client README: store a list of objects in an item - #7458

Merged
adev-code merged 4 commits into
aws:masterfrom
adev-code:gh-2265-readme-list-of-objects
Oct 23, 2026
Merged

adev-code merged 4 commits into
aws:masterfrom
adev-code:gh-2265-readme-list-of-objects

Conversation

@adev-code

@adev-code adev-code commented Oct 17, 2026 •

Copy link
Copy Markdown
Contributor

Motivation and Context

Fixes #2265.

Customer wanted to save a List of their own objects inside an item as a list of maps, not flattened. The DynamoDB Enhanced Client README only shows flattening ("Flat map attributes from another class"), so they couldn't find how to do it. The two working approaches from the issue thread weren't documented in the README.

Modifications

  • services-custom/dynamodb-enhanced/README.md: new section "Store a list of objects inside an item", placed before "Flat map attributes from another class". It shows:
    • how the item is stored (a DynamoDB list of maps),
    • the annotations approach (@DynamoDbBean on both classes, TableSchema.fromBean(...)),
    • the StaticTableSchema approach (EnhancedType.listOf(EnhancedType.documentOf(...))),
    • that addAttribute(List.class, ...) fails with IndexOutOfBoundsException, the error from the issue,
    • a link to "Save complex types" in the AWS SDK for Java 2.x Developer Guide.

No code changes.

Testing

Documentation-only change. The code in the new section was run exactly as written:

  • Real DynamoDB, us-east-1, AWS SDK for Java 2.56.0, Java 17:
    • Annotations approach: the item is saved as recordMetadata = L:[ M:{id, details}, M:{id, details} ] and reads back correctly.
    • StaticTableSchema approach: same stored item, reads back correctly.
    • addAttribute(List.class, ...): building the schema fails with java.lang.IndexOutOfBoundsException: Index: 0 (DefaultAttributeConverterProvider.findConverter reads the list element type with rawClassParameters().get(0), and a raw List.class has none).
  • Both snippets compile with javac -Xlint:all with no warnings. To compile, each class was put in its own file with a package line, and the two static schema fields were put inside a class.
  • Not tested: query/scan/update on these items, @DynamoDbImmutable classes, other SDK versions.

https://github.com/adev-code/aws-sdk-java-v2/blob/gh-2265-readme-list-of-objects/services-custom/dynamodb-enhanced/README.md#store-a-list-of-objects-inside-an-item

License

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

Add a "Store a list of objects inside an item" section that shows how
to save a List of beans as a DynamoDB list of maps, with annotations
(@DynamoDbBean) and with a StaticTableSchema
(EnhancedType.listOf(EnhancedType.documentOf(...))). The README
previously only showed flattening.

Fixes aws#2265
@adev-code
adev-code requested a review from a team as a code owner October 17, 2026 02:02
@adev-code adev-code added the no-api-surface-area-change Indicate there is no API surface area change and thus API surface area review is not required label Oct 17, 2026
@adev-code adev-code mentioned this pull request Oct 17, 2026
@alextwoods
alextwoods self-requested a review October 22, 2026 21:57
@adev-code
adev-code added this pull request to the merge queue Oct 23, 2026
Merged via the queue into aws:master with commit b99fff2 Oct 23, 2026
19 of 22 checks passed
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

no-api-surface-area-change Indicate there is no API surface area change and thus API surface area review is not required

Projects

None yet

Development

Successfully merging this pull request may close these issues.

Dyanmodb Enchanced client nested Objects as json

3 participants