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
376 stars 309 forks source link

Introduce Query and Update objects [DATACASS-343] #514

Closed spring-projects-issues closed 6 years ago

spring-projects-issues commented 7 years ago

Mark Paluch opened DATACASS-343 and commented

Spring Data Cassandra's Template API accepts plain, static CQL and Datastax' Statement types on various method calls. This requires any payload to be already converted to a Cassandra-readable representation. Statement are encapsulated quite well so they don't allow introspection and mapping into different structures.

Introducing Query and Update objects could leverage the mapping issue and reduce method overloads as various options could be integrated into Query (see Spring Data MongoDB). Using Update introduces a wide range of possibilities to partially update data stored inside Cassandra.

User user = …;
UserId userId = …;

Update u = new Update().set("directory", "/Users/Test/Desktop")
                  .add("list", user);
                  .remove("set", userId);

Update u = new Update().increment("counter", 5);

Query q = new Query(where("name")
                  .is("Mark")
                  .and("age").lt(80))
                  .and("map").containsKey(userId)
                  .and("set").contains(user);

Issue Links:

Referenced from: pull request https://github.com/spring-projects/spring-data-cassandra/pull/101

spring-projects-issues commented 7 years ago

John Blum commented

PR #101 reviewed, accepted/polished and committed