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.