Database Reference
In-Depth Information
if(book!=null)
System.out.println(book.getBookTitle() + "\t" +
book.getEdition()
+ "\t" + book.getLanguage());
book1.setLanguage(new HashSet<String>(
Arrays.asList("English", "German", "Latin")));
dynamoDBMapper.save(book1);
} catch (ConditionalCheckFailedException e) {
System.out.println(e.getMessage());
}
Running the preceding code will not give any error because we get the BookEntity
item using the key values Hadoop and 2012-12-28 . Then, we set the Language set
to hold English and German strings to the returned BookEntity item and save it (which
ends the first transaction and updates the version attribute). The code will print the follow-
ing output:
Hadoop 1 [Latin, German, English]
Hadoop 1 [German, English]
Running the following code will result in ConditionalCheckFailedException .
It is exactly the same as that of the previous code, except for the location of dy-
namoDBMapper.save(book) :
try {
BookEntity book = dynamoDBMapper.load(
BookEntity.class, "Hadoop","2012-12-28");
if(book!=null)
System.out.println(book.getBookTitle()
+ "\t" + book.getEdition() + "\t" +
book.getLanguage());
book.setLanguage(new
HashSet<String>(Arrays.asList("English", "German")));
BookEntity book1 = dynamoDBMapper.load(
BookEntity.class, "Hadoop","2012-12-28");
if(book!=null)
System.out.println(book.getBookTitle() + "\t" +
book.getEdition()
Search WWH ::




Custom Search