Skip to content

Conversation

mp911de
Copy link
Member

@mp911de mp911de commented Apr 18, 2017

We now support fluent Query creation for Cassandra queries via Query. Query predicates are built with Criteria and Query that also take QueryOptions, Sort and limiting. Query accepts a column specification to specify column inclusion/exclusion along with function specification (TTL, WRITETIME).

Query query = Query.query(Criteria.where("userId").in("heisenberg", "mike")).and(Criteria.where("age").gt("51")); query = query.columns(Columns.from("userId", "age").include("firstname"))	.with(new Sort("age"))	.with(QueryOptions.builder().fetchSize(10).build())	.withAllowFiltering()	.limit(10); List<Person> people = operations.select(query, Person.class);

Query can be used with select,stream,update and delete Template API methods.

We now support fluent update creation via Update to specify individual update actions for a selection of rows.

Update supports the common Cassandra update assignments for singular, collection and map-typed columns and can increment/decrement counter columns.

Update update = Update.update("lastname", "White")	.addTo("firearms").appendAll("Ruger LCR", "M60")	.remove("propertiesSet", "trust")	.clear("friends"); Query query = Query.query(Criteria.where("id").is("heisenberg")); template.update(query, update, Person.class);

Related ticket: DATACASS-343

Todo:

  • Get feedback (comments)
  • Squash commits
mp911de added 14 commits April 19, 2017 14:33
We now support fluent Query creation for Cassandra queries via Query. Query predicates are built with Criteria and Query that also take QueryOptions, Sort and limiting. Query accepts a column specification to specify column inclusion/exclusion along with function specification (TTL, WRITETIME). Query query = Query.query(Criteria.where("userId").in("heisenberg", "mike")).and(Criteria.where("age").gt("51")); query = query.columns(Columns.from("userId", "age").include("firstname"))	.with(new Sort("age"))	.with(QueryOptions.builder().fetchSize(10).build())	.withAllowFiltering()	.limit(10); List<Person> people = operations.select(query, Person.class); Query can be used with select, stream, update and delete Template API methods.
We now support fluent update creation via Update to specify individual update actions for a selection of rows. Update supports the common Cassandra update assignments for singular, collection and map-typed columns and can increment/decrement counter columns. Update update = Update.update("lastname", "White")	.addTo("firearms").appendAll("Ruger LCR", "M60")	.remove("propertiesSet", "trust")	.clear("friends"); Query query = Query.query(Criteria.where("id").is("heisenberg")); template.update(query, update, Person.class); Update can be used with the update Template API methods.
…methods. We now use Query and Statement instead of formatted String queries to construct executable repository query methods. Using Query allows introspection for column name remapping and value conversion before constructing a Select statement. String queries are now rendered as SimpleStatement with bind markers. Values are attached to the statement and converted to the wire representation on statement execution. Previously, all queries were rendered to String and values were formatted upfront to a String representation.
Enhance JavaDoc. Rename single-letter parameters to meaningful names. Rename UpdateOp to AssignmentOp as single update operations are called assignments in CQL.
Introduce factory methods for Query and Update. Remove ChainedCriteria. Refactor Query and Update to immutable objects. Introduce Operator abstraction for Predicate.
@mp911de mp911de force-pushed the issue/DATACASS-343 branch from 79ba7e1 to e3d8137 Compare April 19, 2017 12:44
@jxblum jxblum self-assigned this May 9, 2017
@jxblum jxblum added complete and removed reviewing labels May 16, 2017
@jxblum jxblum added this to the Kay M4 milestone May 16, 2017
@jxblum
Copy link
Contributor

jxblum commented May 16, 2017

This PR has been reviewed, accepted/polished and committed in revisions... 36ba47e, 3e4016d and 2f4767d.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

2 participants