@ThreadSafe public final class AutoGeneratedTimestampRecordExtension extends Object implements 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.
Modifier and Type | Class and Description |
---|---|
static class |
AutoGeneratedTimestampRecordExtension.AttributeTags
Attribute tag to identify the meta data for
AutoGeneratedTimestampRecordExtension . |
static class |
AutoGeneratedTimestampRecordExtension.Builder
Builder for a
AutoGeneratedTimestampRecordExtension |
Modifier and Type | Method and Description |
---|---|
WriteModification |
beforeWrite(DynamoDbExtensionContext.BeforeWrite context)
This hook is called just before an operation is going to write data to the database.
|
static AutoGeneratedTimestampRecordExtension.Builder |
builder()
Create a builder that can be used to create a
AutoGeneratedTimestampRecordExtension . |
static AutoGeneratedTimestampRecordExtension |
create() |
AutoGeneratedTimestampRecordExtension.Builder |
toBuilder()
Returns a builder initialized with all existing values on the Extension object.
|
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
afterRead
public static AutoGeneratedTimestampRecordExtension.Builder builder()
AutoGeneratedTimestampRecordExtension
.public AutoGeneratedTimestampRecordExtension.Builder toBuilder()
public static AutoGeneratedTimestampRecordExtension create()
AutoGeneratedTimestampRecordExtension
public WriteModification beforeWrite(DynamoDbExtensionContext.BeforeWrite context)
DynamoDbEnhancedClientExtension
beforeWrite
in interface DynamoDbEnhancedClientExtension
context
- The DynamoDbExtensionContext.BeforeWrite
context containing the state of the execution.Copyright © 2023. All rights reserved.