Reputation: 2456
I'm using Spring Boot 1.5.1.RELEASE with spring-boot-starter-data-cassandra.
I'm running into an issue where I'm using CassandraOperations.insert and it is causing a bunch of cell tombstones. This appears to be caused by: https://jira.spring.io/browse/DATACASS-182. Since Spring Data now inserts an actual null for null values, that causes cell tombstones. I haven't found any way to tell Spring Data to not do this. Is there a configuration or something where I can say "for this insert, do not insert actual null values"?
Upvotes: 2
Views: 2098
Reputation: 166
One of the easiest and non intrusive solutions is to use
CassandraTemplate.insert()/CassandraBatchOperations.insert()
Basically tombstones are created when generated CQL has explicit null values. e.g following query will insert one tombstone.
Insert into KeyspaceName.TableName(ColumnName1, ColumnName2, ColumnName3)
values (Column1Value, Column2Value, null)
Cassandra treats insert as upsert and for each null it tries to delete the existing column value without performing check if column value exists or not. So for each null value it creates a tombstone which means value has been deleted.
However following query will not create tombstone.
Insert into KeyspaceName.TableName(ColumnName1, ColumnName2)
values (Column1Value, Column2Value)
Query generated by CassandraTemplate.insert()/CassandraBatchOperations.insert()
ignores columns with null values and generates CQL with columns with non-null values. Hence doesn't create tombstones.
Upvotes: 2
Reputation: 2456
This is currently a limitation with Spring Data Cassandra. I've created https://jira.spring.io/browse/DATACASS-420 to track this. What I did to get around it temporarily was to create a custom class that extends MappingCassandraConverter and I rewrote the writeInsertFromWrapper method to not insert nulls.
Upvotes: 0