Class UpdateBuilder<T>
java.lang.Object
dev.hogwai.dynamodb.simplified.builder.base.AbstractUpdateBuilder<T, UpdateBuilder<T>>
dev.hogwai.dynamodb.simplified.builder.UpdateBuilder<T>
- Type Parameters:
T- the type of the item
A fluent builder for updating an item in a DynamoDB table.
Supports both full-item replacement and partial updates via an
UpdateExpression.
Part of the DynamoDB Simplified library.-
Field Summary
Fields inherited from class AbstractUpdateBuilder
conditionExpression, ignoreNulls, item, keyMap, LOG, optimisticLocking, returnValues, updateExpression -
Constructor Summary
ConstructorsConstructorDescriptionUpdateBuilder(@NonNull software.amazon.awssdk.enhanced.dynamodb.DynamoDbTable<T> table, @NonNull T item, @NonNull software.amazon.awssdk.services.dynamodb.DynamoDbClient dynamoDbClient) Constructs a newUpdateBuilderfor the given table and item.UpdateBuilder(@NonNull software.amazon.awssdk.enhanced.dynamodb.DynamoDbTable<T> table, @NonNull software.amazon.awssdk.services.dynamodb.DynamoDbClient dynamoDbClient, @NonNull Object partitionKey, @Nullable Object sortKey) Key-only constructor for use fromTableconvenience methods. -
Method Summary
Modifier and TypeMethodDescriptionexecute()Executes the update operation.protected @NonNull software.amazon.awssdk.enhanced.dynamodb.KeyReturns aKeybuilt from the current item.protected @NonNull software.amazon.awssdk.enhanced.dynamodb.TableSchema<T> Returns the table schema for the item type.protected @NonNull UpdateBuilder<T> self()Returnsthistyped asSfor fluent chaining.protected @NonNull StringReturns the DynamoDB table name.Methods inherited from class AbstractUpdateBuilder
applyOptimisticLocking, buildKeyMap, buildKeyMapFromValues, condition, condition, ignoreNulls, incrementVersion, returnValues, update, withOptimisticLocking
-
Constructor Details
-
UpdateBuilder
public UpdateBuilder(@NonNull software.amazon.awssdk.enhanced.dynamodb.DynamoDbTable<T> table, @NonNull T item, @NonNull software.amazon.awssdk.services.dynamodb.DynamoDbClient dynamoDbClient) Constructs a newUpdateBuilderfor the given table and item.- Parameters:
table- the DynamoDB tableitem- the item to update (full replacement data, or a template object when used withAbstractUpdateBuilder.update(java.util.function.Consumer))dynamoDbClient- the low-level DynamoDB client (required for partial updates)
-
UpdateBuilder
public UpdateBuilder(@NonNull software.amazon.awssdk.enhanced.dynamodb.DynamoDbTable<T> table, @NonNull software.amazon.awssdk.services.dynamodb.DynamoDbClient dynamoDbClient, @NonNull Object partitionKey, @Nullable Object sortKey) Key-only constructor for use fromTableconvenience methods. Skips the item parameter and builds the key map directly from partition (and optionally sort) key values.- Parameters:
table- the DynamoDB tabledynamoDbClient- the low-level DynamoDB client (required for partial updates)partitionKey- the partition key valuesortKey- the sort key value, ornullif the table has no sort key
-
-
Method Details
-
self
Description copied from class:AbstractUpdateBuilderReturnsthistyped asSfor fluent chaining.- Specified by:
selfin classAbstractUpdateBuilder<T, UpdateBuilder<T>>- Returns:
- this builder
-
tableName
Description copied from class:AbstractUpdateBuilderReturns the DynamoDB table name.- Specified by:
tableNamein classAbstractUpdateBuilder<T, UpdateBuilder<T>>- Returns:
- the DynamoDB table name
-
getKeyFromItem
protected @NonNull software.amazon.awssdk.enhanced.dynamodb.Key getKeyFromItem()Description copied from class:AbstractUpdateBuilderReturns aKeybuilt from the current item. Used internally to build key maps for partial update requests.- Specified by:
getKeyFromItemin classAbstractUpdateBuilder<T, UpdateBuilder<T>>- Returns:
- the key derived from the item
-
getTableSchema
Description copied from class:AbstractUpdateBuilderReturns the table schema for the item type. Used internally for key and attribute conversion.- Specified by:
getTableSchemain classAbstractUpdateBuilder<T, UpdateBuilder<T>>- Returns:
- the table schema
-
execute
Executes the update operation. If a partial update expression was configured viaAbstractUpdateBuilder.update(java.util.function.Consumer), a targeted partial update is performed via the low-level DynamoDB client. Otherwise, the full item is replaced.- Returns:
- the updated item, or empty if not found
-