Class DynamoSimplifiedClient
- All Implemented Interfaces:
DynamoSimplifiedClientInterface, AutoCloseable
Provides factory methods to create a client and access typed Table instances
for DynamoDB table operations. Wraps a DynamoDbEnhancedClient and a
DynamoDbClient.
Thread safety: this client is safe to use from multiple threads once created.
The table() factory method may be called concurrently. Individual builders
returned by Table methods are single-use and not thread-safe.
Usage:
DynamoSimplifiedClient client = DynamoSimplifiedClient.create();
Table<Post> posts = client.table("posts", Post.class);
posts.query().partitionKey("subreddit").executeAll();
- See Also:
-
Method Summary
Modifier and TypeMethodDescription@NonNull CrossTableBatchGetBuilderbatchGet()Returns a cross-table batch get builder for retrieving items from multiple tables.@NonNull CrossTableBatchWriteBuilderReturns a cross-table batch write builder for putting/deleting items across multiple tables.static @NonNull DynamoSimplifiedClientBuilderbuilder()Returns a newDynamoSimplifiedClientBuilderfor building a client with a custom DynamoDB client and/or enhanced client extensions.voidclose()Closes the underlying DynamoDB client, releasing any network resources.static @NonNull DynamoSimplifiedClientcreate()Creates aDynamoSimplifiedClientwith default AWS credentials and region.static @NonNull DynamoSimplifiedClientcreate(@NonNull software.amazon.awssdk.services.dynamodb.DynamoDbClient client) Creates aDynamoSimplifiedClientwith a customDynamoDbClient.@NonNull EntityQueryBuilderentityQuery(@NonNull String tableName) Starts a cross-entity query using the default_typediscriminator attribute.@NonNull EntityQueryBuilderentityQuery(@NonNull String tableName, @NonNull String discriminatorAttribute) Starts a cross-entity query using a custom discriminator attribute.<T> @NonNull EntityTable<T> entityTable(@NonNull Class<T> entityClass) Returns anEntityTablefor the given entity class, enabling single-table design with auto-computed composite keys and discriminator filtering.@NonNull software.amazon.awssdk.services.dynamodb.model.ExecuteStatementResponseexecuteStatement(@NonNull software.amazon.awssdk.services.dynamodb.model.ExecuteStatementRequest request) Executes a PartiQL statement against DynamoDB.@NonNull software.amazon.awssdk.services.dynamodb.DynamoDbClientReturns the underlyingDynamoDbClientfor advanced operations.@NonNull software.amazon.awssdk.enhanced.dynamodb.DynamoDbEnhancedClientReturns the underlyingDynamoDbEnhancedClientfor advanced operations.Lists all DynamoDB tables available to this client.<T> @NonNull Table<T> Returns a typedTablefor the given table name and item class.<T> @NonNull Table<T> table(@NonNull String tableName, @NonNull Class<T> itemClass, @NonNull Consumer<software.amazon.awssdk.enhanced.dynamodb.mapper.StaticTableSchema.Builder<T>> configurator) Returns a typedTablefor the given table name and item class, using aStaticTableSchemaconfigured by the provided consumer.<T> @NonNull Table<T> table(@NonNull String tableName, @NonNull software.amazon.awssdk.enhanced.dynamodb.TableSchema<T> schema) Returns a typedTablefor the given table name and custom schema.@NonNull TransactGetBuilderStarts building a transactional read operation across one or more tables.@NonNull TransactWriteBuilderStarts building a transactional write operation across one or more tables.
-
Method Details
-
builder
Returns a newDynamoSimplifiedClientBuilderfor building a client with a custom DynamoDB client and/or enhanced client extensions.- Returns:
- a new builder instance
-
create
Creates aDynamoSimplifiedClientwith default AWS credentials and region.Builds both the
DynamoDbEnhancedClientand the underlyingDynamoDbClient.- Returns:
- a new
DynamoSimplifiedClientinstance
-
create
public static @NonNull DynamoSimplifiedClient create(@NonNull software.amazon.awssdk.services.dynamodb.DynamoDbClient client) Creates aDynamoSimplifiedClientwith a customDynamoDbClient.Builds the
DynamoDbEnhancedClientfrom the provided client.- Parameters:
client- the DynamoDB client to use- Returns:
- a new
DynamoSimplifiedClientinstance
-
table
Returns a typedTablefor the given table name and item class.The item class must be a valid DynamoDB bean with appropriate annotations.
- Specified by:
tablein interfaceDynamoSimplifiedClientInterface- Type Parameters:
T- the item type- Parameters:
tableName- the name of the DynamoDB tableitemClass- the class of items stored in the table- Returns:
- a
Table<T>for the specified table
-
table
public <T> @NonNull Table<T> table(@NonNull String tableName, @NonNull software.amazon.awssdk.enhanced.dynamodb.TableSchema<T> schema) Returns a typedTablefor the given table name and custom schema.- Specified by:
tablein interfaceDynamoSimplifiedClientInterface- Type Parameters:
T- the item type- Parameters:
tableName- the name of the DynamoDB tableschema- the table schema defining item mapping- Returns:
- a
Table<T>for the specified table
-
table
public <T> @NonNull Table<T> table(@NonNull String tableName, @NonNull Class<T> itemClass, @NonNull Consumer<software.amazon.awssdk.enhanced.dynamodb.mapper.StaticTableSchema.Builder<T>> configurator) Returns a typedTablefor the given table name and item class, using aStaticTableSchemaconfigured by the provided consumer.This is useful when you want to define the table schema programmatically rather than using annotations. Example:
Table<Item> table = client.table("items", Item.class, b -> b .newItemSupplier(Item::new) .addAttribute(String.class, a -> a.name("pk") .getter(Item::getPk) .setter(Item::setPk) .tags(StaticAttributeTags.primaryPartitionKey())) .addAttribute(String.class, a -> a.name("sk") .getter(Item::getSk) .setter(Item::setSk) .tags(StaticAttributeTags.primarySortKey())));- Specified by:
tablein interfaceDynamoSimplifiedClientInterface- Type Parameters:
T- the item type- Parameters:
tableName- the name of the DynamoDB tableitemClass- the class of items stored in the tableconfigurator- a consumer to configure theStaticTableSchema.Builder- Returns:
- a
Table<T>for the specified table
-
entityTable
Returns anEntityTablefor the given entity class, enabling single-table design with auto-computed composite keys and discriminator filtering.The entity class must be annotated with
@Entity. Key components are defined via@KeyComponentand automatically composed into the table's partition/sort keys before every put and update operation. Queries are automatically filtered by the entity's discriminator value.- Specified by:
entityTablein interfaceDynamoSimplifiedClientInterface- Type Parameters:
T- the entity type- Parameters:
entityClass- the entity class annotated with@Entity- Returns:
- an
EntityTable<T>for single-table design
-
entityQuery
Starts a cross-entity query using the default_typediscriminator attribute.- Specified by:
entityQueryin interfaceDynamoSimplifiedClientInterface- Parameters:
tableName- the DynamoDB table shared by the entity types- Returns:
- a cross-entity query builder
-
entityQuery
public @NonNull EntityQueryBuilder entityQuery(@NonNull String tableName, @NonNull String discriminatorAttribute) Starts a cross-entity query using a custom discriminator attribute.- Specified by:
entityQueryin interfaceDynamoSimplifiedClientInterface- Parameters:
tableName- the DynamoDB table shared by the entity typesdiscriminatorAttribute- the attribute containing each entity's discriminator- Returns:
- a cross-entity query builder
-
transactGet
Starts building a transactional read operation across one or more tables.All items are read atomically in a single all-or-nothing transaction.
- Specified by:
transactGetin interfaceDynamoSimplifiedClientInterface- Returns:
- a transact get builder
-
transactWrite
Starts building a transactional write operation across one or more tables.All put, update, delete, and condition check actions are applied atomically.
- Specified by:
transactWritein interfaceDynamoSimplifiedClientInterface- Returns:
- a transact write builder
-
batchGet
Returns a cross-table batch get builder for retrieving items from multiple tables.- Specified by:
batchGetin interfaceDynamoSimplifiedClientInterface- Returns:
- a cross-table batch get builder
-
batchWrite
Returns a cross-table batch write builder for putting/deleting items across multiple tables.- Specified by:
batchWritein interfaceDynamoSimplifiedClientInterface- Returns:
- a cross-table batch write builder
-
getEnhancedClient
public @NonNull software.amazon.awssdk.enhanced.dynamodb.DynamoDbEnhancedClient getEnhancedClient()Returns the underlyingDynamoDbEnhancedClientfor advanced operations.- Specified by:
getEnhancedClientin interfaceDynamoSimplifiedClientInterface- Returns:
- the enhanced DynamoDB client
-
getDynamoDbClient
public @NonNull software.amazon.awssdk.services.dynamodb.DynamoDbClient getDynamoDbClient()Returns the underlyingDynamoDbClientfor advanced operations.- Specified by:
getDynamoDbClientin interfaceDynamoSimplifiedClientInterface- Returns:
- the DynamoDB client
-
listTables
Lists all DynamoDB tables available to this client.Returns a list of table names accessible with the configured AWS credentials.
- Specified by:
listTablesin interfaceDynamoSimplifiedClientInterface- Returns:
- a list of DynamoDB table names
-
executeStatement
public @NonNull software.amazon.awssdk.services.dynamodb.model.ExecuteStatementResponse executeStatement(@NonNull software.amazon.awssdk.services.dynamodb.model.ExecuteStatementRequest request) Executes a PartiQL statement against DynamoDB.This is a passthrough to the underlying low-level
DynamoDbClient.executeStatement(ExecuteStatementRequest). No fluent builder is provided because PartiQL is schemaless and the SDK request is already simple.- Specified by:
executeStatementin interfaceDynamoSimplifiedClientInterface- Parameters:
request- the PartiQL request to execute- Returns:
- the response from DynamoDB
-
close
public void close()Closes the underlying DynamoDB client, releasing any network resources.After calling this method, the client instance is no longer usable.
- Specified by:
closein interfaceAutoCloseable- Specified by:
closein interfaceDynamoSimplifiedClientInterface
-