title: Conditional write item if attribute not equals with DynamoDBMapper
body: <p>Is it possible to do a conditional write/update using DynamoDB mapper when you want to have condition like: Write if attribute is not equal to X?
  I want to do a conditional write that does something like this:</p>
  
  <pre><code>DynamoRecord record = mapper.load(DynamoRecord.class, hashKey);
  if (record.getSomeAttr() != terminationValue) {
      mapper.save(newRecord);
  }
  </code></pre>
  
  <p>The attribute always exists. It can have multiple values and represents a condition after which the updates to the record should stop.</p>
  
  <p>I read <a href="https://java.awsblog.com/post/Tx1JADUVTWF7SP2/Specifying-Conditional-Constraints-with-Amazon-DynamoDB-Mapper" rel="nofollow">this article</a> and <a href="http://docs.aws.amazon.com/AWSJavaSDK/latest/javadoc/com/amazonaws/services/dynamodbv2/datamodeling/DynamoDBSaveExpression.html" rel="nofollow">AWS documentation</a> and a bunch of other posts but seems like only <code>==</code> operator is supported along with exists check. Is it possible to do a <code>!=</code> conditional write using a mapper? If so, any pointers are much appreciated.</p>
  
  <p>Thanks.</p>
  
  <p><strong>Summary from @notionquest's answer</strong></p>
  
  <ol>
  <li>Use <code>ComparisonOperator.NE</code></li>
  <li>If the attribute is a boolean, annotate it using <code>@DynamoDBNativeBoolean</code> for correct results while using <code>ExpectedAttributeValue(new AttributeValue().withBool(true))</code>. See <a href="http://docs.aws.amazon.com/AWSJavaSDK/latest/javadoc/com/amazonaws/services/dynamodbv2/datamodeling/DynamoDBNativeBoolean.html" rel="nofollow">here</a> for details.</li>
  </ol>