Class AutoGeneratedTimestampRecordExtension
- All Implemented Interfaces:
DynamoDbEnhancedClientExtension
This extension is not loaded by default when you instantiate a
DynamoDbEnhancedClient
. Thus you need to specify it in custom extension
while creating the enhanced client.
Example to add AutoGeneratedTimestampRecordExtension along with default extensions is
DynamoDbEnhancedClient.builder().extensions(Stream.concat(ExtensionResolver.defaultExtensions().stream(),
Stream.of(AutoGeneratedTimestampRecordExtension.create())).collect(Collectors.toList())).build();
Example to just add AutoGeneratedTimestampRecordExtension without default extensions is
DynamoDbEnhancedClient.builder().extensions(AutoGeneratedTimestampRecordExtension.create())).build();
To utilize auto generated timestamp update, first create a field in your model that will be used to store the record
timestamp of modification. This class field must be an Instant
Class type, and you need to tag it as the
autoGeneratedTimeStampAttribute. If you are using the
BeanTableSchema
then you should use the
DynamoDbAutoGeneratedTimestampAttribute
annotation, otherwise if you are using the StaticTableSchema
then you should use the AutoGeneratedTimestampRecordExtension.AttributeTags.autoGeneratedTimestampAttribute()
static attribute tag.
Every time a new update of the record is successfully written to the database, the timestamp at which it was modified will be automatically updated. This extension applies the conversions as defined in the attribute convertor.
-
Nested Class Summary
Modifier and TypeClassDescriptionstatic final class
Attribute tag to identify the meta data forAutoGeneratedTimestampRecordExtension
.static final class
Builder for aAutoGeneratedTimestampRecordExtension
-
Method Summary
Modifier and TypeMethodDescriptionThis hook is called just before an operation is going to write data to the database.builder()
Create a builder that can be used to create aAutoGeneratedTimestampRecordExtension
.create()
Returns a builder initialized with all existing values on the Extension object.Methods inherited from class java.lang.Object
equals, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
Methods inherited from interface software.amazon.awssdk.enhanced.dynamodb.DynamoDbEnhancedClientExtension
afterRead
-
Method Details
-
builder
Create a builder that can be used to create aAutoGeneratedTimestampRecordExtension
.- Returns:
- Builder to create AutoGeneratedTimestampRecordExtension,
-
toBuilder
Returns a builder initialized with all existing values on the Extension object. -
create
- Returns:
- an Instance of
AutoGeneratedTimestampRecordExtension
-
beforeWrite
Description copied from interface:DynamoDbEnhancedClientExtension
This hook is called just before an operation is going to write data to the database. The extension that implements this method can choose to transform the item itself, or add a condition to the write operation or both.- Specified by:
beforeWrite
in interfaceDynamoDbEnhancedClientExtension
- Parameters:
context
- TheDynamoDbExtensionContext.BeforeWrite
context containing the state of the execution.- Returns:
- WriteModification Instance updated with attribute updated with Extension.
-