I am using the Azure SDK for Java and working with Azure Storage Tables. I am trying to update fields in a row and the code I am using is as below
TableClient tableClient = getTableClient();
String myPartitionKey = "partitionkey";
String myRowKey = "rowkey";
List<String> propertiesToSelect = new ArrayList<>();
propertiesToSelect.add("field9");
propertiesToSelect.add("field10");
Response<TableEntity> response = tableClient.getEntityWithResponse(myPartitionKey, myRowKey, propertiesToSelect,
Duration.ofSeconds(5), null);
TableEntity tableEntity = response.getValue();
Map<String, Object> properties = tableEntity.getProperties();
properties.put("field9", "value9");
properties.put("field10", "value10");
tableClient.updateEntity(tableEntity, TableEntityUpdateMode.MERGE);
What is happening is that the field values are getting updated but along with there some fields having names starting with "odata" are also being added to the rows.
How do I prevent these fields from being added to the rows?
Thanks for your help.
The solution was to create a new entity with the same partition key and row key. Then add the property we are attempting to update and then update the entity in the merge mode.
TableEntity tableEntity = new TableEntity("partitionKey", "rowKey");
tableEntity.addProperty("Version", version);
tableEntity.addProperty("TimeStamp", myTimestamp);
tableClient.updateEntity(tableEntity, TableEntityUpdateMode.MERGE);