Rohit Kasat
Rohit Kasat

Reputation: 300

Cassandra update vs insert. How to set a column to null [using insert]?

Cassandra insert is kind of update except the fields which are being overwritten. If those are null it will keep the old values and will not overwrite it with null.

Example: Table t1 with x, y columns using x as primary key.

Data: x= "xxx" y ="yyy"

INSERT (x,y) VALUES ("xxx", "zzz") will work fine. UPDATE (x,y) VALUES("xxx") will not set y to null.

I am using Spring Data Cassandra which has Repositories. Repositories don't have methods to update it just a method to create. When I try to explicitly set value null, it skips those value and insert is not working exactly like update.

How can I set null values using Spring Data Cassandra values while insert?

Upvotes: 2

Views: 2455

Answers (1)

mp911de
mp911de

Reputation: 18137

Spring Data Cassandra skips currently (in version 1.4.1.RELEASE) null values on insert(…) and update(…). Your current only option is using plain CQL in that case. We have an open ticket to allow insertion of null values.

Upvotes: 1

Related Questions