0

I have been trying to use DynamoDB mapper for creating save expressions. I want to save a record iff

  1. A particular attribute value doesn't exist. OR
  2. That attribute value should be greater than a particular value.

So I have created an expression for it, but it throws IllegalArgumentException.

expected.put("date",
                new ExpectedAttributeValue(new AttributeValue()
                        .withN(Long.toString(date.toEpochMilli())))
                        .withComparisonOperator(ComparisonOperator.LT));
        expected.put("date", new ExpectedAttributeValue(false));
        saveExpression.withConditionalOperator(ConditionalOperator.OR);
saveExpression.setExpected(expected);

This is the kind of exception I'm getting.

java.lang.IllegalArgumentException: Unable to assert the value of the fields [version], since the expected value conditions cannot be combined with user-specified conditions joined by "OR"

I was wondering if I'm missing something or is there something wrong??

Edit

Looks like I couldn't use an OR operation between two internal conditions. Is it possible to do OR-ing in some way?? Thanks in advance.

NoSQLKnowHow
  • 4,449
  • 23
  • 35
  • check if this is relevant to what your error is described. It mentioned to `You can use SaveBehavior.CLOBBER to skip the assertion on these fields.` https://github.com/aws/aws-sdk-java/blob/2abc7e64630cf3c6e76455af8d975ae4c452dc39/aws-java-sdk-dynamodb/src/main/java/com/amazonaws/services/dynamodbv2/datamodeling/DynamoDBMapper.java#L2223 – sham Jun 02 '21 at 02:31
  • @sham... Looks like I can't use OR between 2 internal conditions. Is there any way to use OR?? – neethu narayanan Jun 02 '21 at 03:22

0 Answers0