Reputation: 231
I am trying to insert a row using following piece of code:
Item item = new Item().withPrimaryKey("id", id).withString(
"owner", owner);
if (properties != null) {
item.withMap("property", properties);
}
Expected expected = new Expected(id).notExist();
return table.putItem(item, expected).toString();
This is not supposed to update if entry with "id" with provided id already exists in the table. However, this is still updating the entry in the table with the new values.
What am I doing wrong here?
Upvotes: 1
Views: 673
Reputation: 47259
You are providing the attribute value to the Expected
constructor when the constructor is for the attribute name.
public Expected(java.lang.String attrName)
You should change from using the parameter/hash key value id
Expected expected = new Expected(id).notExist();
to use the attribute name
Expected expected = new Expected("id").notExist();
Upvotes: 1