java - Conditional write item if attribute not equals with DynamoDBMapper -


is possible conditional write/update using dynamodb mapper when want have condition like: write if attribute not equal x? want conditional write this:

dynamorecord record = mapper.load(dynamorecord.class, hashkey); if (record.getsomeattr() != terminationvalue) {     mapper.save(newrecord); } 

the attribute exists. can have multiple values , represents condition after updates record should stop.

i read this article , aws documentation , bunch of other posts seems == operator supported along exists check. possible != conditional write using mapper? if so, pointers appreciated.

thanks.

summary @notionquest's answer

  1. use comparisonoperator.ne
  2. if attribute boolean, annotate using @dynamodbnativeboolean correct results while using expectedattributevalue(new attributevalue().withbool(true)). see here details.

please use "withcomparisonoperator(comparisonoperator.ne)" notequals condition. refer below example.

dynamodbsaveexpression saveexpression = new dynamodbsaveexpression();        map expected = new hashmap();        expected.put("status",            new expectedattributevalue(new attributevalue(status)).withcomparisonoperator(comparisonoperator.ne)); saveexpression.setexpected(expected); dynamodbmapper.save(obj, saveexpression); 

Comments

Popular posts from this blog

PySide and Qt Properties: Connecting signals from Python to QML -

c# - DevExpress.Wpf.Grid.InfiniteGridSizeException was unhandled -

scala - 'wrong top statement declaration' when using slick in IntelliJ -