spring-projects / spring-data-cassandra

Provides support to increase developer productivity in Java when using Apache Cassandra. Uses familiar Spring concepts such as a template classes for core API usage and lightweight repository style data access.
https://spring.io/projects/spring-data-cassandra/
Apache License 2.0
374 stars 307 forks source link

Ability to null out column values [DATACASS-182] #353

Closed spring-projects-issues closed 7 years ago

spring-projects-issues commented 9 years ago

praveena subrahmanyam opened DATACASS-182 and commented

Sometimes there is a need to null out values previously set column values.

Also, since in cassandra an insert is treated as an upsert. It would be good to have the option to clear out previously set values in the case where an insert is actually an update.


Affects: 1.3.4 (Gosling SR4), 1.4.2 (Hopper SR2)

Issue Links:

Referenced from: pull request https://github.com/spring-projects/spring-data-cassandra/pull/72, and commits https://github.com/spring-projects/spring-data-cassandra/commit/f63d2cb26a386d632c98123bcd52639961555d82, https://github.com/spring-projects/spring-data-cassandra/commit/6ee70916ff7e89fa58292e0e63cb0acf6a6bbed5, https://github.com/spring-projects/spring-data-cassandra/commit/e10c71722dec1f1caea5b71e2133ec23e79762fb

4 votes, 8 watchers

spring-projects-issues commented 9 years ago

Adam Walczak - WALCZAK.IT commented

yep, this makes String Cassandra Repositories quite unusable for us

the problem is in this line here: https://github.com/spring-projects/spring-data-cassandra/blob/master/spring-data-cassandra/src/main/java/org/springframework/data/cassandra/convert/MappingCassandraConverter.java#L256

we had to implement our own update methods for each entity instead of using save for updates

spring-projects-issues commented 9 years ago

Adam Walczak - WALCZAK.IT commented

pull request: https://github.com/spring-projects/spring-data-cassandra/pull/34

spring-projects-issues commented 8 years ago

Christoph Emmersberger commented

We ran into the same issue using spring-data JPA for cassandra String repositories and were wondering, if the listed pull request would be sufficient to solve the issue. I looked into the referenced pull requests and figured that most of them have been closed without any additional comments. Can anyone (e.g. Oliver Drotbohm, ...) provide a bit more detail as of why writing NULL may or may not be a great idea when working with Cassandra? These are the referenced pull requests:

spring-projects-issues commented 8 years ago

Mark Paluch commented

I haven't found any reason so far why null values should be skipped in INSERT and DELETE methods. Assigning null to columns in the early days of CQL using INSERT and UPDATE wasn't working. I suppose that's just a left-over of the early CQL stage

spring-projects-issues commented 8 years ago

John Blum commented

PR #72 merged!