Use advanced mapping features
Learn about advanced table schema features in the DynamoDB Enhanced Client API.
Understand table schema types
TableSchema
is the interface to the mapping functionality of the
DynamoDB Enhanced Client API. It can map a data object to and from a map of AttributeValuesTableSchema
object needs to know about the
structure of the table it is mapping. This structure information is stored in a TableMetadata
The enhanced client API has several implementations of TableSchema
, which
follow.
Table schema generated from annotated classes
It is a moderately expensive operation to build a TableSchema
from
annotated classes, so we recommend doing this once, at application startup.
-
BeanTableSchema
-
This implementation is built based on attributes and annotations of a bean class. An example of this approach is demonstrated in the Get started section.
Note
If a
BeanTableSchema
is not behaving as you expect, enable debug logging forsoftware.amazon.awssdk.enhanced.dynamodb.beans
. - ImmutableTableSchema
-
This implementation is built from an immutable data class. This approach is described in the Work with immutable data classes section.
Table schema generated with a builder
The following TableSchema
s are built from code by using a builder. This
approach is less costly than the approach that uses annotated data classes. The builder
approach avoids the use of annotations and doesn't require JavaBean naming standards.
- StaticTableSchema
-
This implementation is built for mutable data classes. The getting started section of this guide demonstrated how to generate a StaticTableSchema using a builder.
- StaticImmutableTableSchema
-
Similarly to how you build a
StaticTableSchema
, you generate an implementation of this type ofTableSchema
using a builderfor use with immutable data classes.
Table schema for data without a fixed schema
- DocumentTableSchema
-
Unlike other implementations of
TableSchema
, you don't define attributes for aDocumentTableSchema
instance. Usually, you specify only primary keys and attribute converter providers. AnEnhancedDocument
instance provides the attributes that you build from individual elements or from a JSON string.