Class VersionedRecordExtension
- All Implemented Interfaces:
DynamoDbEnhancedClientExtension
This extension is loaded by default when you instantiate a
DynamoDbEnhancedClient so unless you are using a custom extension
there is no need to specify it.
To utilize versioned record locking, first create an attribute in your model that will be used to store the record
version number. This attribute must be an 'integer' type numeric (long or integer), and you need to tag it as the
version attribute. If you are using the BeanTableSchema then
you should use the DynamoDbVersionAttribute
annotation, otherwise if you are using the StaticTableSchema
then you should use the VersionedRecordExtension.AttributeTags.versionAttribute() static attribute tag.
Then, whenever a record is written the write operation will only succeed if the version number of the record has not been modified since it was last read by the application. Every time a new version of the record is successfully written to the database, the record version number will be automatically incremented.
-
Nested Class Summary
Nested ClassesModifier and TypeClassDescriptionstatic final classstatic final class -
Method Summary
Modifier and TypeMethodDescriptionThis hook is called just before an operation is going to write data to the database.builder()Methods inherited from class java.lang.Object
equals, getClass, hashCode, notify, notifyAll, toString, wait, wait, waitMethods inherited from interface software.amazon.awssdk.enhanced.dynamodb.DynamoDbEnhancedClientExtension
afterRead
-
Method Details
-
builder
-
beforeWrite
Description copied from interface:DynamoDbEnhancedClientExtensionThis 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:
beforeWritein interfaceDynamoDbEnhancedClientExtension- Parameters:
context- TheDynamoDbExtensionContext.BeforeWritecontext containing the state of the execution.- Returns:
- A
WriteModificationobject that can alter the behavior of the write operation.
-