Class TransactGetBuilder
java.lang.Object
dev.hogwai.dynamodb.simplified.builder.base.AbstractTransactGetBuilder<TransactGetBuilder>
dev.hogwai.dynamodb.simplified.builder.TransactGetBuilder
Builds a transactional get operation that reads up to 100 items atomically
across one or more tables.
Obtain via DynamoSimplifiedClient.transactGet().
All items are retrieved in a single all-or-nothing transaction. If any item cannot be read, the entire transaction fails and no results are returned.
Note: DynamoDB's TransactGetItems API does not support ConsistentRead. This is an API-level limitation and cannot be worked around through any code path.
-
Nested Class Summary
Nested classes/interfaces inherited from class AbstractTransactGetBuilder
AbstractTransactGetBuilder.Entry -
Field Summary
Fields inherited from class AbstractTransactGetBuilder
entries -
Constructor Summary
ConstructorsConstructorDescriptionTransactGetBuilder(@NonNull software.amazon.awssdk.enhanced.dynamodb.DynamoDbEnhancedClient enhancedClient, @NonNull software.amazon.awssdk.services.dynamodb.DynamoDbClient dynamoDbClient) Constructs a transactional get builder. -
Method Summary
Modifier and TypeMethodDescription<T> @NonNull TransactGetBuilderaddGetItem(@NonNull Table<T> table, @NonNull Object partitionKey) Adds an item to retrieve by partition key.<T> @NonNull TransactGetBuilderaddGetItem(@NonNull Table<T> table, @NonNull Object partitionKey, @NonNull Object sortKey) Adds an item to retrieve by partition and sort key.@NonNull TransactGetResults<software.amazon.awssdk.enhanced.dynamodb.DynamoDbTable<?>> execute()Executes the transactional get operation.protected @NonNull StringgetTableName(@NonNull AbstractTransactGetBuilder.Entry entry) Extracts the DynamoDB table name from an entry's table reference.protected @NonNull software.amazon.awssdk.enhanced.dynamodb.TableSchema<?> getTableSchema(@NonNull AbstractTransactGetBuilder.Entry entry) Extracts the table schema from an entry's table reference.protected @NonNull TransactGetBuilderself()Returnsthistyped asSfor fluent chaining.Methods inherited from class AbstractTransactGetBuilder
buildKey, buildTransactItems, hasNonEmptyProjection, project, project
-
Constructor Details
-
TransactGetBuilder
public TransactGetBuilder(@NonNull software.amazon.awssdk.enhanced.dynamodb.DynamoDbEnhancedClient enhancedClient, @NonNull software.amazon.awssdk.services.dynamodb.DynamoDbClient dynamoDbClient) Constructs a transactional get builder.Typically obtained via
DynamoSimplifiedClient.transactGet().- Parameters:
enhancedClient- the enhanced DynamoDB clientdynamoDbClient- the low-level DynamoDB client (used for projection fallback)
-
-
Method Details
-
self
Description copied from class:AbstractTransactGetBuilderReturnsthistyped asSfor fluent chaining.- Specified by:
selfin classAbstractTransactGetBuilder<TransactGetBuilder>- Returns:
- this builder
-
getTableName
Description copied from class:AbstractTransactGetBuilderExtracts the DynamoDB table name from an entry's table reference.- Specified by:
getTableNamein classAbstractTransactGetBuilder<TransactGetBuilder>- Parameters:
entry- the entry whose table name to extract- Returns:
- the DynamoDB table name
-
getTableSchema
protected @NonNull software.amazon.awssdk.enhanced.dynamodb.TableSchema<?> getTableSchema(@NonNull AbstractTransactGetBuilder.Entry entry) Description copied from class:AbstractTransactGetBuilderExtracts the table schema from an entry's table reference.- Specified by:
getTableSchemain classAbstractTransactGetBuilder<TransactGetBuilder>- Parameters:
entry- the entry whose table schema to extract- Returns:
- the table schema
-
addGetItem
public <T> @NonNull TransactGetBuilder addGetItem(@NonNull Table<T> table, @NonNull Object partitionKey) Adds an item to retrieve by partition key.- Type Parameters:
T- the item type- Parameters:
table- the typed table to read frompartitionKey- the partition key value- Returns:
- this builder
-
addGetItem
public <T> @NonNull TransactGetBuilder addGetItem(@NonNull Table<T> table, @NonNull Object partitionKey, @NonNull Object sortKey) Adds an item to retrieve by partition and sort key.- Type Parameters:
T- the item type- Parameters:
table- the typed table to read frompartitionKey- the partition key valuesortKey- the sort key value- Returns:
- this builder
-
execute
public @NonNull TransactGetResults<software.amazon.awssdk.enhanced.dynamodb.DynamoDbTable<?>> execute()Executes the transactional get operation.If any item has a projection expression configured via
AbstractTransactGetBuilder.project(String...), the operation falls back to the low-level DynamoDB API to support attribute filtering.- Returns:
- a
TransactGetResultsobject providing typed access to retrieved items
-