Database Reference
In-Depth Information
// Hash key of item to be updated
HashMap<String, AttributeValue> primaryKeyForCredit = new
HashMap<String, AttributeValue>();
primaryKeyForCredit.put("accountNumber", new
AttributeValue().withN("2002"));
// Add 100 to the exiting balance
updateItemsForCredit.put("balance",
new AttributeValueUpdate()
.withAction(AttributeAction.ADD)
.withValue(new AttributeValue()
.withN("100")));
UpdateItemRequest creditRequest = new UpdateItemRequest()
.withTableName("Bank").withKey(primaryKey1)
.withReturnValues(ReturnValue.UPDATED_NEW)
.withAttributeUpdates(updateItems1);
// Execute the transaction
tx.updateItem(creditRequest);
At this time, we would have the values updated in the tables, but this is not yet committed.
So let's commit the transaction using the following code:
tx.commit();
Once this statement is executed, only then do you see that the values are committed.
Isolated reads
The Transaction library supports three different levels of isolation as follows:
• Fully isolated
• Committed
• Uncommitted
Search WWH ::




Custom Search