Java Code Examples for com.amazonaws.services.dynamodbv2.datamodeling.DynamoDBMapper#batchWrite()
The following examples show how to use
com.amazonaws.services.dynamodbv2.datamodeling.DynamoDBMapper#batchWrite() .
You can vote up the ones you like or vote down the ones you don't like,
and go to the original project or source file by following the links above each example. You may check out the related API usage on the sidebar.
Example 1
Source File: DynamoDBMapperBatchWriteExample.java From aws-doc-sdk-examples with Apache License 2.0 | 5 votes |
private static void testBatchWrite(DynamoDBMapper mapper) { // Create Forum item to save Forum forumItem = new Forum(); forumItem.name = "Test BatchWrite Forum"; forumItem.threads = 0; forumItem.category = "Amazon Web Services"; // Create Thread item to save Thread threadItem = new Thread(); threadItem.forumName = "AmazonDynamoDB"; threadItem.subject = "My sample question"; threadItem.message = "BatchWrite message"; List<String> tags = new ArrayList<String>(); tags.add("batch operations"); tags.add("write"); threadItem.tags = new HashSet<String>(tags); // Load ProductCatalog item to delete Book book3 = mapper.load(Book.class, 903); List<Object> objectsToWrite = Arrays.asList(forumItem, threadItem); List<Book> objectsToDelete = Arrays.asList(book3); DynamoDBMapperConfig config = DynamoDBMapperConfig.builder() .withSaveBehavior(DynamoDBMapperConfig.SaveBehavior.CLOBBER) .build(); mapper.batchWrite(objectsToWrite, objectsToDelete, config); }
Example 2
Source File: ObjectPersistenceBatchWriteExample.java From aws-dynamodb-examples with Apache License 2.0 | 5 votes |
private static void testBatchWrite(DynamoDBMapper mapper) { // Create Forum item to save Forum forumItem = new Forum(); forumItem.name = "Test BatchWrite Forum"; forumItem.threads = 0; forumItem.category = "Amazon Web Services"; // Create Thread item to save Thread threadItem = new Thread(); threadItem.forumName = "AmazonDynamoDB"; threadItem.subject = "My sample question"; threadItem.message = "BatchWrite message"; List<String> tags = new ArrayList<String>(); tags.add("batch operations"); tags.add("write"); threadItem.tags = new HashSet<String>(tags); // Load ProductCatalog item to delete Book book3 = mapper.load(Book.class, 903); List<Object> objectsToWrite = Arrays.asList(forumItem, threadItem); List<Book> objectsToDelete = Arrays.asList(book3); DynamoDBMapperConfig config = new DynamoDBMapperConfig(DynamoDBMapperConfig.SaveBehavior.CLOBBER); mapper.batchWrite(objectsToWrite, objectsToDelete, config); }