Data class annotations - Amazon SDK for Java 2.x
Services or capabilities described in Amazon Web Services documentation might vary by Region. To see the differences applicable to the China Regions, see Getting Started with Amazon Web Services in China (PDF).

Data class annotations

The following table lists the annotations that can be used on data classes and provides links to information and examples in this guide. The table is sorted in ascending alphabetical order by annotation name.

Data class annotations used in this guide
Annotation name Annotation applies to1 What it does Where it is shown in this guide
DynamoDbAtomicCounter attribute2 Increments a tagged numerical attribute each time a record is written to the database. Introduction and discussion.
DynamoDbAttribute attribute Defines or renames a bean property that is mapped to a DynamoDB table attribute.
DynamoDbAutoGeneratedTimestampAttribute attribute Updates a tagged attribute with a current timestamp every time the item is successfully written to the database Introduction and discussion.
DynamoDbBean class Marks a data class as mappable to a table schema. First use on the Customer class in the Get started section. Several usages appear throughout the guide.
DynamoDbConvertedBy attribute Associates a custom AttributeConverter with the annotated attribute. Initial discussion and example.
DynamoDbFlatten attribute Flattens all the attributes of a separate DynamoDB data class and adds them as top-level attributes to the record that is read and written to the database.
DynamoDbIgnore attribute

Results in the attribute remaining unmapped.

DynamoDbIgnoreNulls attribute Prevents saving null attributes of nested DynamoDb objects. Discussion and examples.
DynamoDbImmutable class

Marks an immutable data class as mappable to a table schema.

DynamoDbPartitionKey attribute

Marks an attribute as the primary partition key (hash key) of the DynamoDb table.

DynamoDbPreserveEmptyObject attribute

Specifies that if no data is present for the object mapped to the annotated attribute, the object should be initialized with all null fields.

Discussion and examples.
DynamoDbSecondaryPartitionKey attribute

Marks an attribute as a partition key for a global secondary index.

DynamoDbSecondarySortKey attribute

Marks an attribute as an optional sort key for a global or local secondary index.

DynamoDbSortKey attribute

Marks an attribute as the optional primary sort key (range key).

DynamoDbUpdateBehavior attribute

Specifies the behavior when this attribute is updated as part of an 'update' operation such as UpdateItem.

Introduction and example.
DynamoDbVersionAttribute attribute Increments an item version number. Introduction and discussion.

1You can apply an attribute-level annotations to the getter or setter, but not both. This guide shows annotations on getters.

2The term property is normally used for a value encapsulated in a JavaBean data class. However, this guide uses the term attribute instead, to be consistent with the terminology used by DynamoDB.