View a markdown version of this page

DynamoDB Mapper annotations reference - AWS SDK for Kotlin

DynamoDB Mapper annotations reference

This page lists the annotations used to generate schemas from your classes, as described in Generate a schema from annotations. Apply them to a class and its properties, then let the schema-generator plugin produce the schema.

All item annotations are in the aws.sdk.kotlin.hll.dynamodbmapper package and are provided by the dynamodb-mapper-annotations dependency.

Annotations

The following table lists the annotations alphabetically.

Annotation Applies to Parameters Behavior

@DynamoDbAttribute

Property

name: String

Maps the property to a DynamoDB attribute with the given name instead of the property name.

@DynamoDbAttributeConverter

Property

converter: KClass<out ValueConverter<*>>

Uses the specified ValueConverter for this property, for types the generator doesn’t map on its own.

@DynamoDbCounter

Property

(none)

Marks a numeric property as an atomic counter that increments each time the item is persisted. See Built-in features for runtime behavior.

@DynamoDbIgnore

Property

(none)

Excludes the property from mapping; it’s neither written nor read.

@DynamoDbItem

Class

converter: KClass<out ItemConverter<*>> (defaults to an auto-generated converter)

Marks a class as a mapped item type. All public properties are mapped unless ignored.

@DynamoDbPartitionKey

Property

(none)

Marks the property as the partition key. Every top-level item type must have exactly one.

@DynamoDbSortKey

Property

(none)

Marks the property as the sort key. A top-level item type can have at most one.

@DynamoDbTtlSeconds

Property

lifetime: Long

Marks a property used to track the item’s time-to-live (TTL), with the given lifetime in seconds. See Built-in features for runtime behavior.

Opt-in annotations

The following annotation is not a schema annotation; it gates an opt-in API surface.

  • @ManualPagination (aws.sdk.kotlin.hll.dynamodbmapper.annotations): a @RequiresOptIn marker on the non-paginating query and scan operations. Opt in at the call site with @OptIn(ManualPagination::class) when you need to manage pagination tokens yourself. See Manual pagination in the Operations overview.