Class DefaultDynamoDbTable<T>
- java.lang.Object
-
- software.amazon.awssdk.enhanced.dynamodb.internal.client.DefaultDynamoDbTable<T>
-
- All Implemented Interfaces:
DynamoDbTable<T>
,MappedTableResource<T>
public class DefaultDynamoDbTable<T> extends Object implements DynamoDbTable<T>
-
-
Method Summary
All Methods Instance Methods Concrete Methods Modifier and Type Method Description void
createTable()
Creates a new table in DynamoDb with the name and schema already defined for this DynamoDbTable.void
createTable(Consumer<CreateTableEnhancedRequest.Builder> requestConsumer)
Creates a new table in DynamoDb with the name and schema already defined for this DynamoDbTable together with additional parameters specified in the supplied request object,CreateTableEnhancedRequest
.void
createTable(CreateTableEnhancedRequest request)
Creates a new table in DynamoDb with the name and schema already defined for this DynamoDbTable together with additional parameters specified in the supplied request object,CreateTableEnhancedRequest
.T
deleteItem(Consumer<DeleteItemEnhancedRequest.Builder> requestConsumer)
Deletes a single item from the mapped table using a supplied primaryKey
.T
deleteItem(Key key)
Deletes a single item from the mapped table using a supplied primaryKey
.T
deleteItem(DeleteItemEnhancedRequest request)
Deletes a single item from the mapped table using a supplied primaryKey
.T
deleteItem(T keyItem)
Deletes a single item from the mapped table using just the key of a supplied modelled 'key item' object.DeleteItemEnhancedResponse<T>
deleteItemWithResponse(Consumer<DeleteItemEnhancedRequest.Builder> requestConsumer)
Deletes a single item from the mapped table using a supplied primaryKey
.DeleteItemEnhancedResponse<T>
deleteItemWithResponse(DeleteItemEnhancedRequest request)
Deletes a single item from the mapped table using a supplied primaryKey
.void
deleteTable()
Deletes a table in DynamoDb with the name and schema already defined for this DynamoDbTable.DescribeTableEnhancedResponse
describeTable()
Describes a table in DynamoDb with the name defined for thisDynamoDbTable
.DynamoDbClient
dynamoDbClient()
boolean
equals(Object o)
T
getItem(Consumer<GetItemEnhancedRequest.Builder> requestConsumer)
Retrieves a single item from the mapped table using a supplied primaryKey
.T
getItem(Key key)
Retrieves a single item from the mapped table using a supplied primaryKey
.T
getItem(GetItemEnhancedRequest request)
Retrieves a single item from the mapped table using a supplied primaryKey
.T
getItem(T keyItem)
Retrieves a single item from the mapped table using just the key of a supplied modelled 'key item'.GetItemEnhancedResponse<T>
getItemWithResponse(Consumer<GetItemEnhancedRequest.Builder> requestConsumer)
Retrieves a single item from the mapped table using a supplied primaryKey
.GetItemEnhancedResponse<T>
getItemWithResponse(GetItemEnhancedRequest request)
Retrieves a single item from the mapped table using a supplied primaryKey
.int
hashCode()
DefaultDynamoDbIndex<T>
index(String indexName)
Returns a mapped index that can be used to execute commands against a secondary index belonging to the table being mapped by this object.Key
keyFrom(T item)
Creates aKey
object from a modelled item.DynamoDbEnhancedClientExtension
mapperExtension()
Gets theDynamoDbEnhancedClientExtension
associated with this mapped resource.void
putItem(Consumer<PutItemEnhancedRequest.Builder<T>> requestConsumer)
Puts a single item in the mapped table.void
putItem(PutItemEnhancedRequest<T> request)
Puts a single item in the mapped table.void
putItem(T item)
Puts a single item in the mapped table.PutItemEnhancedResponse<T>
putItemWithResponse(Consumer<PutItemEnhancedRequest.Builder<T>> requestConsumer)
Puts a single item in the mapped table.PutItemEnhancedResponse<T>
putItemWithResponse(PutItemEnhancedRequest<T> request)
Puts a single item in the mapped table.PageIterable<T>
query(Consumer<QueryEnhancedRequest.Builder> requestConsumer)
This is a convenience method that creates an instance of the request builder avoiding the need to create one manually viaQueryEnhancedRequest.builder()
.PageIterable<T>
query(QueryConditional queryConditional)
Executes a query against the primary index of the table using aQueryConditional
expression to retrieve a list of items matching the given conditions.PageIterable<T>
query(QueryEnhancedRequest request)
Executes a query against the primary index of the table using aQueryConditional
expression to retrieve a list of items matching the given conditions.PageIterable<T>
scan()
Scans the table and retrieves all items using default settings.PageIterable<T>
scan(Consumer<ScanEnhancedRequest.Builder> requestConsumer)
This is a convenience method that creates an instance of the request builder avoiding the need to create one manually viaScanEnhancedRequest.builder()
.PageIterable<T>
scan(ScanEnhancedRequest request)
Scans the table and retrieves all items.String
tableName()
Gets the physical table name that operations performed by this object will be executed against.TableSchema<T>
tableSchema()
Gets theTableSchema
object that this mapped table was built with.T
updateItem(Consumer<UpdateItemEnhancedRequest.Builder<T>> requestConsumer)
Updates an item in the mapped table, or adds it if it doesn't exist.T
updateItem(UpdateItemEnhancedRequest<T> request)
Updates an item in the mapped table, or adds it if it doesn't exist.T
updateItem(T item)
Updates an item in the mapped table, or adds it if it doesn't exist.UpdateItemEnhancedResponse<T>
updateItemWithResponse(Consumer<UpdateItemEnhancedRequest.Builder<T>> requestConsumer)
Updates an item in the mapped table, or adds it if it doesn't exist.UpdateItemEnhancedResponse<T>
updateItemWithResponse(UpdateItemEnhancedRequest<T> request)
Updates an item in the mapped table, or adds it if it doesn't exist.
-
-
-
Method Detail
-
mapperExtension
public DynamoDbEnhancedClientExtension mapperExtension()
Description copied from interface:MappedTableResource
Gets theDynamoDbEnhancedClientExtension
associated with this mapped resource.- Specified by:
mapperExtension
in interfaceMappedTableResource<T>
- Returns:
- The
DynamoDbEnhancedClientExtension
associated with this mapped resource.
-
tableSchema
public TableSchema<T> tableSchema()
Description copied from interface:MappedTableResource
Gets theTableSchema
object that this mapped table was built with.- Specified by:
tableSchema
in interfaceMappedTableResource<T>
- Returns:
- The
TableSchema
object for this mapped table.
-
dynamoDbClient
public DynamoDbClient dynamoDbClient()
-
tableName
public String tableName()
Description copied from interface:MappedTableResource
Gets the physical table name that operations performed by this object will be executed against.- Specified by:
tableName
in interfaceMappedTableResource<T>
- Returns:
- The physical table name.
-
index
public DefaultDynamoDbIndex<T> index(String indexName)
Description copied from interface:DynamoDbTable
Returns a mapped index that can be used to execute commands against a secondary index belonging to the table being mapped by this object. Note that only a subset of the commands that work against a table will work against a secondary index.- Specified by:
index
in interfaceDynamoDbTable<T>
- Parameters:
indexName
- The name of the secondary index to build the command interface for.- Returns:
- A
DynamoDbIndex
object that can be used to execute database commands against.
-
createTable
public void createTable(CreateTableEnhancedRequest request)
Description copied from interface:DynamoDbTable
Creates a new table in DynamoDb with the name and schema already defined for this DynamoDbTable together with additional parameters specified in the supplied request object,CreateTableEnhancedRequest
.Use
DynamoDbEnhancedClient.table(String, TableSchema)
to define the mapped table resource.This operation calls the low-level DynamoDB API CreateTable operation. Note that this is an asynchronous operation and that the table may not immediately be available for writes and reads. You can use
DynamoDbWaiter.waitUntilTableExists(DescribeTableRequest)
to wait for the resource to be ready.Example:
ProvisionedThroughput provisionedThroughput = ProvisionedThroughput.builder() .readCapacityUnits(50L) .writeCapacityUnits(50L) .build(); mappedTable.createTable(CreateTableEnhancedRequest.builder() .provisionedThroughput(provisionedThroughput) .build()); dynamoDbClient.waiter().waitUntilTableExists(b -> b.tableName(tableName));
- Specified by:
createTable
in interfaceDynamoDbTable<T>
- Parameters:
request
- ACreateTableEnhancedRequest
containing optional parameters for table creation.
-
createTable
public void createTable(Consumer<CreateTableEnhancedRequest.Builder> requestConsumer)
Description copied from interface:DynamoDbTable
Creates a new table in DynamoDb with the name and schema already defined for this DynamoDbTable together with additional parameters specified in the supplied request object,CreateTableEnhancedRequest
.Use
DynamoDbEnhancedClient.table(String, TableSchema)
to define the mapped table resource.This operation calls the low-level DynamoDB API CreateTable operation. Note that this is an asynchronous operation and that the table may not immediately be available for writes and reads. You can use
DynamoDbWaiter.waitUntilTableExists(DescribeTableRequest)
to wait for the resource to be ready.Note: This is a convenience method that creates an instance of the request builder avoiding the need to create one manually via
CreateTableEnhancedRequest.builder()
.Example:
ProvisionedThroughput provisionedThroughput = ProvisionedThroughput.builder() .readCapacityUnits(50L) .writeCapacityUnits(50L) .build(); mappedTable.createTable(r -> r.provisionedThroughput(provisionedThroughput)); dynamoDbClient.waiter().waitUntilTableExists(b -> b.tableName(tableName));
- Specified by:
createTable
in interfaceDynamoDbTable<T>
- Parameters:
requestConsumer
- AConsumer
ofCreateTableEnhancedRequest.Builder
containing optional parameters for table creation.
-
createTable
public void createTable()
Description copied from interface:DynamoDbTable
Creates a new table in DynamoDb with the name and schema already defined for this DynamoDbTable.Use
DynamoDbEnhancedClient.table(String, TableSchema)
to define the mapped table resource.This operation calls the low-level DynamoDB API CreateTable operation. Note that this is an asynchronous operation and that the table may not immediately be available for writes and reads. You can use
DynamoDbWaiter.waitUntilTableExists(DescribeTableRequest)
to wait for the resource to be ready.Example:
mappedTable.createTable(); dynamoDbClient.waiter().waitUntilTableExists(b -> b.tableName(tableName));
- Specified by:
createTable
in interfaceDynamoDbTable<T>
-
deleteItem
public T deleteItem(DeleteItemEnhancedRequest request)
Description copied from interface:DynamoDbTable
Deletes a single item from the mapped table using a supplied primaryKey
.The additional configuration parameters that the enhanced client supports are defined in the
DeleteItemEnhancedRequest
.This operation calls the low-level DynamoDB API DeleteItem operation. Consult the DeleteItem documentation for further details and constraints.
Example:
MyItem previouslyPersistedItem = mappedTable.delete(DeleteItemEnhancedRequest.builder().key(key).build());
- Specified by:
deleteItem
in interfaceDynamoDbTable<T>
- Parameters:
request
- ADeleteItemEnhancedRequest
with key and optional directives for deleting an item from the table.- Returns:
- The item that was persisted in the database before it was deleted.
-
deleteItem
public T deleteItem(Consumer<DeleteItemEnhancedRequest.Builder> requestConsumer)
Description copied from interface:DynamoDbTable
Deletes a single item from the mapped table using a supplied primaryKey
.The additional configuration parameters that the enhanced client supports are defined in the
DeleteItemEnhancedRequest
.This operation calls the low-level DynamoDB API DeleteItem operation. Consult the DeleteItem documentation for further details and constraints.
Note: This is a convenience method that creates an instance of the request builder avoiding the need to create one manually via
DeleteItemEnhancedRequest.builder()
.Example:
MyItem previouslyPersistedItem = mappedTable.delete(r -> r.key(key));
- Specified by:
deleteItem
in interfaceDynamoDbTable<T>
- Parameters:
requestConsumer
- AConsumer
ofDeleteItemEnhancedRequest
with key and optional directives for deleting an item from the table.- Returns:
- The item that was persisted in the database before it was deleted.
-
deleteItem
public T deleteItem(Key key)
Description copied from interface:DynamoDbTable
Deletes a single item from the mapped table using a supplied primaryKey
.This operation calls the low-level DynamoDB API DeleteItem operation. Consult the DeleteItem documentation for further details and constraints.
Example:
MyItem previouslyPersistedItem = mappedTable.delete(key);
- Specified by:
deleteItem
in interfaceDynamoDbTable<T>
- Parameters:
key
- AKey
that will be used to match a specific record to delete from the database table.- Returns:
- The item that was persisted in the database before it was deleted.
-
deleteItem
public T deleteItem(T keyItem)
Description copied from interface:DynamoDbTable
Deletes a single item from the mapped table using just the key of a supplied modelled 'key item' object.This operation calls the low-level DynamoDB API DeleteItem operation. Consult the DeleteItem documentation for further details and constraints.
Example:
MyItem previouslyPersistedItem = mappedTable.deleteItem(keyItem);
- Specified by:
deleteItem
in interfaceDynamoDbTable<T>
- Parameters:
keyItem
- A modelled item with the primary key fields set that will be used to match a specific record to delete from the database table.- Returns:
- The item that was persisted in the database before it was deleted.
-
deleteItemWithResponse
public DeleteItemEnhancedResponse<T> deleteItemWithResponse(DeleteItemEnhancedRequest request)
Description copied from interface:DynamoDbTable
Deletes a single item from the mapped table using a supplied primaryKey
.The additional configuration parameters that the enhanced client supports are defined in the
DeleteItemEnhancedRequest
.This operation calls the low-level DynamoDB API DeleteItem operation. Consult the DeleteItem documentation for further details and constraints. Unlike
DynamoDbTable.deleteItem(DeleteItemEnhancedRequest)
, this returns a response object, allowing the user to retrieve additional information from DynamoDB related to the API call, such asConsumedCapacity
if specified on the request.Example:
DeleteItemEnhancedRequest request = DeleteItemEnhancedRequest.builder().key(key).build(); DeleteItemEnhancedResponse<MyItem> response = mappedTable.deleteItemWithResponse(request);
- Specified by:
deleteItemWithResponse
in interfaceDynamoDbTable<T>
- Parameters:
request
- ADeleteItemEnhancedRequest
with key and optional directives for deleting an item from the table.- Returns:
- The response returned by DynamoDB.
-
deleteItemWithResponse
public DeleteItemEnhancedResponse<T> deleteItemWithResponse(Consumer<DeleteItemEnhancedRequest.Builder> requestConsumer)
Description copied from interface:DynamoDbTable
Deletes a single item from the mapped table using a supplied primaryKey
.The additional configuration parameters that the enhanced client supports are defined in the
DeleteItemEnhancedRequest
.This operation calls the low-level DynamoDB API DeleteItem operation. Consult the DeleteItem documentation for further details and constraints. Unlike
DynamoDbTable.deleteItem(Consumer)
, this returns a response object, allowing the user to retrieve additional information from DynamoDB related to the API call, such asConsumedCapacity
if specified on the request.Note: This is a convenience method that creates an instance of the request builder avoiding the need to create one manually via
DeleteItemEnhancedRequest.builder()
.Example:
DeleteItemEnhancedResponse<MyItem> response = mappedTable.deleteWithResponse(r -> r.key(key));
- Specified by:
deleteItemWithResponse
in interfaceDynamoDbTable<T>
- Parameters:
requestConsumer
- AConsumer
ofDeleteItemEnhancedRequest
with key and optional directives for deleting an item from the table.- Returns:
- The response returned by DynamoDB.
-
getItem
public T getItem(GetItemEnhancedRequest request)
Description copied from interface:DynamoDbTable
Retrieves a single item from the mapped table using a supplied primaryKey
.The additional configuration parameters that the enhanced client supports are defined in the
GetItemEnhancedRequest
.This operation calls the low-level DynamoDB API GetItem operation. Consult the GetItem documentation for further details and constraints.
Example:
MyItem item = mappedTable.getItem(GetItemEnhancedRequest.builder().key(key).build());
- Specified by:
getItem
in interfaceDynamoDbTable<T>
- Parameters:
request
- AGetItemEnhancedRequest
with key and optional directives for retrieving an item from the table.- Returns:
- The retrieved item
-
getItem
public T getItem(Consumer<GetItemEnhancedRequest.Builder> requestConsumer)
Description copied from interface:DynamoDbTable
Retrieves a single item from the mapped table using a supplied primaryKey
.The additional configuration parameters that the enhanced client supports are defined in the
GetItemEnhancedRequest
.This operation calls the low-level DynamoDB API GetItem operation. Consult the GetItem documentation for further details and constraints.
Note: This is a convenience method that creates an instance of the request builder avoiding the need to create one manually via
GetItemEnhancedRequest.builder()
.Example:
MyItem item = mappedTable.getItem(r -> r.key(key));
- Specified by:
getItem
in interfaceDynamoDbTable<T>
- Parameters:
requestConsumer
- AConsumer
ofGetItemEnhancedRequest.Builder
with key and optional directives for retrieving an item from the table.- Returns:
- The retrieved item
-
getItem
public T getItem(Key key)
Description copied from interface:DynamoDbTable
Retrieves a single item from the mapped table using a supplied primaryKey
.This operation calls the low-level DynamoDB API GetItem operation. Consult the GetItem documentation for further details and constraints.
Example:
MyItem item = mappedTable.getItem(key);
- Specified by:
getItem
in interfaceDynamoDbTable<T>
- Parameters:
key
- AKey
that will be used to match a specific record to retrieve from the database table.- Returns:
- The retrieved item
-
getItem
public T getItem(T keyItem)
Description copied from interface:DynamoDbTable
Retrieves a single item from the mapped table using just the key of a supplied modelled 'key item'.This operation calls the low-level DynamoDB API GetItem operation. Consult the GetItem documentation for further details and constraints.
Example:
MyItem item = mappedTable.getItem(keyItem);
- Specified by:
getItem
in interfaceDynamoDbTable<T>
- Parameters:
keyItem
- A modelled item with the primary key fields set that will be used to match a specific record to retrieve from the database table.- Returns:
- The retrieved item
-
getItemWithResponse
public GetItemEnhancedResponse<T> getItemWithResponse(Consumer<GetItemEnhancedRequest.Builder> requestConsumer)
Description copied from interface:DynamoDbTable
Retrieves a single item from the mapped table using a supplied primaryKey
. This is similar to#getItem(Consumer
but returns) GetItemEnhancedResponse
for additional information.The additional configuration parameters that the enhanced client supports are defined in the
GetItemEnhancedRequest
.This operation calls the low-level DynamoDB API GetItem operation. Consult the GetItem documentation for further details and constraints.
Note: This is a convenience method that creates an instance of the request builder avoiding the need to create one manually via
GetItemEnhancedRequest.builder()
.Example:
MyItem item = mappedTable.getItemWithResponse(r -> r.key(key));
- Specified by:
getItemWithResponse
in interfaceDynamoDbTable<T>
- Parameters:
requestConsumer
- AConsumer
ofGetItemEnhancedRequest.Builder
with key and optional directives for retrieving an item from the table.- Returns:
- The retrieved item
-
getItemWithResponse
public GetItemEnhancedResponse<T> getItemWithResponse(GetItemEnhancedRequest request)
Description copied from interface:DynamoDbTable
Retrieves a single item from the mapped table using a supplied primaryKey
. This is similar toDynamoDbTable.getItem(GetItemEnhancedRequest)
but returnsGetItemEnhancedResponse
for additional information.The additional configuration parameters that the enhanced client supports are defined in the
GetItemEnhancedRequest
.This operation calls the low-level DynamoDB API GetItem operation. Consult the GetItem documentation for further details and constraints.
Example:
MyItem item = mappedTable.getItemWithResponse(GetItemEnhancedRequest.builder().key(key).build());
- Specified by:
getItemWithResponse
in interfaceDynamoDbTable<T>
- Parameters:
request
- AGetItemEnhancedRequest
with key and optional directives for retrieving an item from the table.- Returns:
- The retrieved item
-
query
public PageIterable<T> query(QueryEnhancedRequest request)
Description copied from interface:DynamoDbTable
Executes a query against the primary index of the table using aQueryConditional
expression to retrieve a list of items matching the given conditions.The result can be accessed either through iterable
Page
s orPage.items()
directly. If you are iterating the pages, the result is accessed through iterable pages (seePage
) in an interactive way; each time a result page is retrieved, a query call is made to DynamoDb to get those entries. If no matches are found, the resulting iterator will contain an empty page. Results are sorted by sort key value in ascending order by default; this behavior can be overridden in theQueryEnhancedRequest
.The additional configuration parameters that the enhanced client supports are defined in the
QueryEnhancedRequest
.This operation calls the low-level DynamoDB API Query operation. Consult the Query documentation for further details and constraints.
Example:
1) Iterating through pages
QueryConditional queryConditional = QueryConditional.keyEqualTo(Key.builder().partitionValue("id-value").build()); PageIterable<MyItem> results = table.query(QueryEnhancedRequest.builder() .queryConditional(queryConditional) .build()); results.stream().forEach(p -> p.items().forEach(item -> System.out.println(item)))
results.items().stream().forEach(item -> System.out.println(item));
- Specified by:
query
in interfaceDynamoDbTable<T>
- Parameters:
request
- AQueryEnhancedRequest
defining the query conditions and how to handle the results.- Returns:
- an iterator of type
SdkIterable
with paginated results (seePage
). - See Also:
DynamoDbTable.query(QueryConditional)
,DynamoDbTable.query(Consumer)
,DynamoDbClient.queryPaginator(software.amazon.awssdk.services.dynamodb.model.QueryRequest)
-
query
public PageIterable<T> query(Consumer<QueryEnhancedRequest.Builder> requestConsumer)
Description copied from interface:DynamoDbTable
This is a convenience method that creates an instance of the request builder avoiding the need to create one manually viaQueryEnhancedRequest.builder()
.Example:
PageIterable<MyItem> results = mappedTable.query(r -> r.queryConditional(QueryConditional.keyEqualTo(k -> k.partitionValue("id-value"))));
- Specified by:
query
in interfaceDynamoDbTable<T>
- Parameters:
requestConsumer
- AConsumer
ofQueryEnhancedRequest
defining the query conditions and how to handle the results.- Returns:
- an iterator of type
SdkIterable
with paginated results (seePage
). - See Also:
DynamoDbTable.query(QueryEnhancedRequest)
,DynamoDbTable.query(QueryConditional)
-
query
public PageIterable<T> query(QueryConditional queryConditional)
Description copied from interface:DynamoDbTable
Executes a query against the primary index of the table using aQueryConditional
expression to retrieve a list of items matching the given conditions.Example:
PageIterable<MyItem> results = mappedTable.query(QueryConditional.keyEqualTo(Key.builder().partitionValue("id-value").build()));
- Specified by:
query
in interfaceDynamoDbTable<T>
- Parameters:
queryConditional
- AQueryConditional
defining the matching criteria for records to be queried.- Returns:
- an iterator of type
SdkIterable
with paginated results (seePage
). - See Also:
DynamoDbTable.query(QueryEnhancedRequest)
,DynamoDbTable.query(Consumer)
,DynamoDbClient.queryPaginator(software.amazon.awssdk.services.dynamodb.model.QueryRequest)
-
putItem
public void putItem(PutItemEnhancedRequest<T> request)
Description copied from interface:DynamoDbTable
Puts a single item in the mapped table. If the table contains an item with the same primary key, it will be replaced with this item.The additional configuration parameters that the enhanced client supports are defined in the
PutItemEnhancedRequest
.This operation calls the low-level DynamoDB API PutItem operation. Consult the PutItem documentation for further details and constraints.
Example:
mappedTable.putItem(PutItemEnhancedRequest.builder(MyItem.class).item(item).build());
- Specified by:
putItem
in interfaceDynamoDbTable<T>
- Parameters:
request
- APutItemEnhancedRequest
that includes the item to enter into the table, its class and optional directives.
-
putItem
public void putItem(Consumer<PutItemEnhancedRequest.Builder<T>> requestConsumer)
Description copied from interface:DynamoDbTable
Puts a single item in the mapped table. If the table contains an item with the same primary key, it will be replaced with this item.The additional configuration parameters that the enhanced client supports are defined in the
PutItemEnhancedRequest
.This operation calls the low-level DynamoDB API PutItem operation. Consult the PutItem documentation for further details and constraints.
Example:
mappedTable.putItem(r -> r.item(item));
- Specified by:
putItem
in interfaceDynamoDbTable<T>
- Parameters:
requestConsumer
- AConsumer
ofPutItemEnhancedRequest.Builder
that includes the item to enter into the table, its class and optional directives.
-
putItem
public void putItem(T item)
Description copied from interface:DynamoDbTable
Puts a single item in the mapped table. If the table contains an item with the same primary key, it will be replaced with this item.This operation calls the low-level DynamoDB API PutItem operation. Consult the PutItem documentation for further details and constraints.
Example:
mappedTable.putItem(item);
- Specified by:
putItem
in interfaceDynamoDbTable<T>
- Parameters:
item
- the modelled item to be inserted into or overwritten in the database table.
-
putItemWithResponse
public PutItemEnhancedResponse<T> putItemWithResponse(PutItemEnhancedRequest<T> request)
Description copied from interface:DynamoDbTable
Puts a single item in the mapped table. If the table contains an item with the same primary key, it will be replaced with this item. This is similar toDynamoDbTable.putItem(PutItemEnhancedRequest)
but returnsPutItemEnhancedResponse
for additional information.The additional configuration parameters that the enhanced client supports are defined in the
PutItemEnhancedRequest
.This operation calls the low-level DynamoDB API PutItem operation. Consult the PutItem documentation for further details and constraints.
Example:
mappedTable.putItem(PutItemEnhancedRequest.builder(MyItem.class).item(item).build());
- Specified by:
putItemWithResponse
in interfaceDynamoDbTable<T>
- Parameters:
request
- APutItemEnhancedRequest
that includes the item to enter into the table, its class and optional directives.- Returns:
- The response returned by DynamoDB.
-
putItemWithResponse
public PutItemEnhancedResponse<T> putItemWithResponse(Consumer<PutItemEnhancedRequest.Builder<T>> requestConsumer)
Description copied from interface:DynamoDbTable
Puts a single item in the mapped table. If the table contains an item with the same primary key, it will be replaced with this item. This is similar toDynamoDbTable.putItem(PutItemEnhancedRequest)
but returnsPutItemEnhancedResponse
for additional information.The additional configuration parameters that the enhanced client supports are defined in the
PutItemEnhancedRequest
.This operation calls the low-level DynamoDB API PutItem operation. Consult the PutItem documentation for further details and constraints.
Example:
mappedTable.putItem(PutItemEnhancedRequest.builder(MyItem.class).item(item).build());
- Specified by:
putItemWithResponse
in interfaceDynamoDbTable<T>
- Parameters:
requestConsumer
- AConsumer
ofPutItemEnhancedRequest.Builder
that includes the item to enter into the table, its class and optional directives.- Returns:
- The response returned by DynamoDB.
-
scan
public PageIterable<T> scan(ScanEnhancedRequest request)
Description copied from interface:DynamoDbTable
Scans the table and retrieves all items.The result can be accessed either through iterable
Page
s or items across all pages directly. Each time a result page is retrieved, a query call is made to DynamoDb to get those entries. If no matches are found, the resulting iterator will contain an empty page.The additional configuration parameters that the enhanced client supports are defined in the
ScanEnhancedRequest
.Example:
1) Iterating through pages
PageIterable<MyItem> results = mappedTable.scan(ScanEnhancedRequest.builder().consistentRead(true).build()); results.stream().forEach(p -> p.items().forEach(item -> System.out.println(item)))
2) Iterating through items
PageIterable<MyItem> results = mappedTable.scan(ScanEnhancedRequest.builder().consistentRead(true).build()); results.items().stream().forEach(item -> System.out.println(item));
- Specified by:
scan
in interfaceDynamoDbTable<T>
- Parameters:
request
- AScanEnhancedRequest
defining how to handle the results.- Returns:
- an iterator of type
SdkIterable
with paginated results (seePage
). - See Also:
DynamoDbTable.scan(Consumer)
,DynamoDbTable.scan()
,DynamoDbClient.scanPaginator(software.amazon.awssdk.services.dynamodb.model.ScanRequest)
-
scan
public PageIterable<T> scan(Consumer<ScanEnhancedRequest.Builder> requestConsumer)
Description copied from interface:DynamoDbTable
This is a convenience method that creates an instance of the request builder avoiding the need to create one manually viaScanEnhancedRequest.builder()
.Example:
PageIterable<MyItem> results = mappedTable.scan(r -> r.limit(5));
- Specified by:
scan
in interfaceDynamoDbTable<T>
- Parameters:
requestConsumer
- AConsumer
ofScanEnhancedRequest
defining the query conditions and how to handle the results.- Returns:
- an iterator of type
SdkIterable
with paginated results (seePage
). - See Also:
DynamoDbTable.scan(ScanEnhancedRequest)
,DynamoDbTable.scan()
-
scan
public PageIterable<T> scan()
Description copied from interface:DynamoDbTable
Scans the table and retrieves all items using default settings.The result can be accessed either through iterable
Page
s or items across all pages directly. Each time a result page is retrieved, a query call is made to DynamoDb to get those entries. If no matches are found, the resulting iterator will contain an empty page.Example:
PageIterable<MyItem> results = mappedTable.scan();
- Specified by:
scan
in interfaceDynamoDbTable<T>
- Returns:
- an iterator of type
SdkIterable
with paginated results (seePage
). - See Also:
DynamoDbTable.scan(ScanEnhancedRequest)
,DynamoDbTable.scan(Consumer)
,DynamoDbClient.scanPaginator(software.amazon.awssdk.services.dynamodb.model.ScanRequest)
-
updateItem
public T updateItem(UpdateItemEnhancedRequest<T> request)
Description copied from interface:DynamoDbTable
Updates an item in the mapped table, or adds it if it doesn't exist.The additional configuration parameters that the enhanced client supports are defined in the
UpdateItemEnhancedRequest
.This operation calls the low-level DynamoDB API UpdateItem operation. Consult the UpdateItem documentation for further details and constraints.
Example:
MyItem item = mappedTable.updateItem(UpdateItemEnhancedRequest.builder(MyItem.class).item(item).build());
- Specified by:
updateItem
in interfaceDynamoDbTable<T>
- Parameters:
request
- AUpdateItemEnhancedRequest
that includes the item to be updated, its class and optional directives.- Returns:
- The updated item
-
updateItem
public T updateItem(Consumer<UpdateItemEnhancedRequest.Builder<T>> requestConsumer)
Description copied from interface:DynamoDbTable
Updates an item in the mapped table, or adds it if it doesn't exist.The additional configuration parameters that the enhanced client supports are defined in the
UpdateItemEnhancedRequest
.This operation calls the low-level DynamoDB API UpdateItem operation. Consult the UpdateItem documentation for further details and constraints.
Example:
MyItem item = mappedTable.updateItem(r -> r.item(item));
- Specified by:
updateItem
in interfaceDynamoDbTable<T>
- Parameters:
requestConsumer
- AConsumer
ofUpdateItemEnhancedRequest.Builder
that includes the item to be updated, its class and optional directives.- Returns:
- The updated item
-
updateItem
public T updateItem(T item)
Description copied from interface:DynamoDbTable
Updates an item in the mapped table, or adds it if it doesn't exist.This operation calls the low-level DynamoDB API UpdateItem operation. Consult the UpdateItem documentation for further details and constraints.
Example:
MyItem item = mappedTable.updateItem(item);
- Specified by:
updateItem
in interfaceDynamoDbTable<T>
- Parameters:
item
- the modelled item to be inserted into or updated in the database table.- Returns:
- The updated item
-
updateItemWithResponse
public UpdateItemEnhancedResponse<T> updateItemWithResponse(UpdateItemEnhancedRequest<T> request)
Description copied from interface:DynamoDbTable
Updates an item in the mapped table, or adds it if it doesn't exist. This is similar toDynamoDbTable.updateItem(UpdateItemEnhancedRequest)
} but returnsUpdateItemEnhancedResponse
for additional information.This operation calls the low-level DynamoDB API UpdateItem operation. Consult the UpdateItem documentation for further details and constraints.
Example:
UpdateItemEnhancedRequest<MyItem> request = UpdateItemEnhancedRequest.builder(MyItem.class).item(myItem).build(); UpdateItemEnhancedResponse<MyItem> response = mappedTable.updateItemWithResponse(request);
- Specified by:
updateItemWithResponse
in interfaceDynamoDbTable<T>
- Parameters:
request
- the modelled item to be inserted into or updated in the database table.- Returns:
- The response returned by DynamoDB.
-
updateItemWithResponse
public UpdateItemEnhancedResponse<T> updateItemWithResponse(Consumer<UpdateItemEnhancedRequest.Builder<T>> requestConsumer)
Description copied from interface:DynamoDbTable
Updates an item in the mapped table, or adds it if it doesn't exist. This is similar toDynamoDbTable.updateItem(Consumer)
but returnsUpdateItemEnhancedResponse
for additional information.This operation calls the low-level DynamoDB API UpdateItem operation. Consult the UpdateItem documentation for further details and constraints.
Example:
UpdateItemEnhancedResponse<MyItem> response = mappedTable.updateItemWithResponse(r ->r.item(myItem));
- Specified by:
updateItemWithResponse
in interfaceDynamoDbTable<T>
- Parameters:
requestConsumer
- AConsumer
ofUpdateItemEnhancedRequest.Builder
that includes the item * to be updated, its class and optional directives.- Returns:
- The response from DynamoDB.
-
keyFrom
public Key keyFrom(T item)
Description copied from interface:MappedTableResource
Creates aKey
object from a modelled item. This key can be used in query conditionals and get operations to locate a specific record.- Specified by:
keyFrom
in interfaceMappedTableResource<T>
- Parameters:
item
- The item to extract the key fields from.- Returns:
- A key that has been initialized with the index values extracted from the modelled object.
-
deleteTable
public void deleteTable()
Description copied from interface:DynamoDbTable
Deletes a table in DynamoDb with the name and schema already defined for this DynamoDbTable.Use
DynamoDbEnhancedClient.table(String, TableSchema)
to define the mapped table resource.This operation calls the low-level DynamoDB API DeleteTable operation. Note that this is an asynchronous operation and that the table may not immediately be deleted. You can use
DynamoDbWaiter.waitUntilTableNotExists(software.amazon.awssdk.services.dynamodb.model.DescribeTableRequest)
in the underlying client.Example:
mappedTable.deleteTable();
- Specified by:
deleteTable
in interfaceDynamoDbTable<T>
-
describeTable
public DescribeTableEnhancedResponse describeTable()
Description copied from interface:DynamoDbTable
Describes a table in DynamoDb with the name defined for thisDynamoDbTable
. This operation calls the low-level DynamoDB API DescribeTable operation, seeDynamoDbClient.describeTable(DescribeTableRequest)
Example:
DescribeTableEnhancedResponse response = mappedTable.describeTable();
- Specified by:
describeTable
in interfaceDynamoDbTable<T>
-
-