title: DynamoDB: How to perform conditional write to enforce unique Hash + Range key
body: <p>I am using DynamoDB to store events.
  They are stored in 1 event table with a hash key 'Source ID' and a range key 'version'. Every time a new event occurs for a source, i want to add a new item with the source ID and an increased version nr.</p>
  
  <p>Is it possible to specify a conditional write so that a duplicate item (same hash key and same range key) can never exist? And if so, how would you do this?</p>
  
  <p>I have done this successfully for tables with just a Hash Key:</p>
  
  <pre><code>Map&lt;String, ExpectedAttributeValue&gt; expected = new HashMap&lt;String, ExpectedAttributeValue&gt;();
  expected.put("key", new ExpectedAttributeValue().withExists(false));
  </code></pre>
  
  <p>But not sure how to handle hash + range keys....</p>