Main API changes¶
The
Query
class has been renamed intoStatement
(it was confusing to some that theBoundStatement
was not aStatement
). To allow this, the oldStatement
class has been renamed toRegularStatement
.The
Cluster
andSession
shutdown API has changed. There is now acloseAsync
that is asynchronous but returns aFuture
on the completion of the shutdown process. There is also aclose
shortcut that does the same but blocks. Also,close
now waits for ongoing queries to complete by default (but you can force the closing of all connections if you want to).NoHostAvailableException#getErrors
now returns the full exception objects for each node instead of just a message. In other words, it returns aMap<InetAddress, Throwable>
instead of aMap<InetAddress, String>
.Statement#getConsistencyLevel
(previouslyQuery#getConsistencyLevel
, see first point) will now returnnull
by default (instead ofCL.ONE
), with the meaning of “use the default consistency level”. The default consistency level can now be configured through the newQueryOptions
object in the clusterConfiguration
.The
Metrics
class now uses the Codahale metrics library version 3 (version 2 was used previously). This new major version of the library has many API changes compared to its version 2 (see the release notes for details), which can thus impact consumers of the Metrics class. Furthermore, the defaultJmxReporter
now includes a name specific to the cluster instance (to avoid conflicts when multiple Cluster instances are created in the same JVM). As a result, tools that were polling JMX info will have to be updated accordingly.The
QueryBuilder#in
method now has the following special case: usingQueryBuilder.in(QueryBuilder.bindMarker())
will generate the stringIN ?
, notIN (?)
as was the case in 1.0. The reasoning being that the former syntax, made valid by CASSANDRA-4210 is a lot more useful thanIN (?)
, as the latter can more simply use an equality. Note that if you really want to outputIN (?)
with the query builder, you can useQueryBuilder.in(QueryBuilder.raw("?"))
.When binding values by name in
BoundStatement
(i.e. using thesetX(String, X)
methods), if more than one variable have the same name, then all values corresponding to that variable name are set instead of just the first occurrence.The
QueryBuilder#raw
method does not automatically add quotes anymore, but rather output its result without any change (as the raw name implies). This means for instance thateq("x", raw(foo))
will outputx = foo
, notx = 'foo'
(you don’t need the raw method to output the latter string).The
QueryBuilder
will now sometimes use the new ability to send value as bytes instead of serializing everything to string. In general the QueryBuilder will do the right thing, but if you were calling thegetQueryString()
method on a Statement created with a QueryBuilder (for other reasons than to prepare a query) then the returned string may contain bind markers in place of some of the values provided (and in that case,getValues()
will contain the values corresponding to those markers). If need be, it is possible to force the old behavior by using the newsetForceNoValues()
method.