You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
I'm wondering if I can accomplish what I want here while using DynamoDBMapper. I really want to avoid the AmazonDynamoDB client since it would increase the complexity of my code tenfold.
Here is my situation:
My database stores 4 different item types - Foo, Bar, and Baz, and Bang.
All of these item types include a version field annotated with @DynamoDBVersionAttribute to utilize optimistic locking.
To optimize reads, Baz items contain denormalized data from Foo and Bar. There is a Map attribute type which contains the JSON of the related Foo and Bar objects.
I am trying to write a Transaction with the following conditions:
The transaction should write a new Baz and Bang object
The transaction should fail if Foo and Bar items are updated. This is because the denormalized data for these items in Baz will now be out of date.
ConditionCheck — Applies a condition to an item that is not being modified by the transaction. This structure specifies the primary key of the item to be checked, the name of the table where it resides, a condition expression that must be satisfied for the transaction to succeed, and a field indicating whether to retrieve the item's attributes if the condition is not met.
Using DynamoDBMapper, my code looks like the below (note: DynamoDBItem is a custom interface which allows me to pass around Dynamo mapped objects of different types).
However, this throws the error A transactional write operation may not also specify a condition expression if a versioned attribute is present on the model of the item.
Is there any way to do what I want with the DynamoDBMapper? Can anyone offer me advice here? Thank you very much.
reacted with thumbs up emoji reacted with thumbs down emoji reacted with laugh emoji reacted with hooray emoji reacted with confused emoji reacted with heart emoji reacted with rocket emoji reacted with eyes emoji
-
I'm wondering if I can accomplish what I want here while using DynamoDBMapper. I really want to avoid the AmazonDynamoDB client since it would increase the complexity of my code tenfold.
Here is my situation:
version
field annotated with@DynamoDBVersionAttribute
to utilize optimistic locking.Luckily, it looks like DynamoDB supports exactly what I want https://docs.aws.amazon.com/amazondynamodb/latest/APIReference/API_TransactWriteItems.html
Using DynamoDBMapper, my code looks like the below (note: DynamoDBItem is a custom interface which allows me to pass around Dynamo mapped objects of different types).
However, this throws the error A transactional write operation may not also specify a condition expression if a versioned attribute is present on the model of the item.
Is there any way to do what I want with the DynamoDBMapper? Can anyone offer me advice here? Thank you very much.
Beta Was this translation helpful? Give feedback.
All reactions