com.datastax.driver.core
Class Query

java.lang.Object
  extended by com.datastax.driver.core.Query
Direct Known Subclasses:
BoundStatement, Statement

public abstract class Query
extends Object

An executable query.

This represents either a Statement or a BoundStatement along with the query options (consistency level, whether to trace the query, ...).


Method Summary
 Query disableTracing()
          Disables tracing for this query.
 Query enableTracing()
          Enables tracing for this query.
 ConsistencyLevel getConsistencyLevel()
          Returns the consistency level.
 RetryPolicy getRetryPolicy()
          Returns the retry policy sets for this query, if any.
abstract  ByteBuffer getRoutingKey()
          Returns the routing key (in binary raw form) to use for token aware routing of this query.
 boolean isTracing()
          Returns whether tracing is enabled for this query or not.
 Query setConsistencyLevel(ConsistencyLevel consistency)
          Sets the consistency level for the query.
 Query setRetryPolicy(RetryPolicy policy)
          Sets the retry policy to use for this query.
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Method Detail

setConsistencyLevel

public Query setConsistencyLevel(ConsistencyLevel consistency)
Sets the consistency level for the query.

The default consistency level, if this method is not called, is ConsistencyLevel.ONE.

Parameters:
consistency - the consistency level to set.
Returns:
this Query object.

getConsistencyLevel

public ConsistencyLevel getConsistencyLevel()
Returns the consistency level.

Returns:
the consistency level, which is ConsistencyLevel.ONE if no consistency level has been specified.

enableTracing

public Query enableTracing()
Enables tracing for this query. By default (that is unless you call this method), tracing is not enabled.

Returns:
this Query object.

disableTracing

public Query disableTracing()
Disables tracing for this query.

Returns:
this Query object.

isTracing

public boolean isTracing()
Returns whether tracing is enabled for this query or not.

Returns:
true if this query has tracing enabled, false otherwise.

getRoutingKey

public abstract ByteBuffer getRoutingKey()
Returns the routing key (in binary raw form) to use for token aware routing of this query.

The routing key is optional in that implementers are free to return null. The routing key is an hint used for token-aware routing (see TokenAwarePolicy), and if provided should correspond to the binary value for the query partition key. However, not providing a routing key never causes a query to fail and if the load balancing policy used is not token aware, then the routing key can be safely ignored.

Returns:
the routing key for this query or null.

setRetryPolicy

public Query setRetryPolicy(RetryPolicy policy)
Sets the retry policy to use for this query.

The default retry policy, if this method is not called, is the one returned by Policies.getRetryPolicy() in the cluster configuration. This method is thus only useful in case you want to punctually override the default policy for this request.

Parameters:
policy - the retry policy to use for this query.
Returns:
this Query object.

getRetryPolicy

public RetryPolicy getRetryPolicy()
Returns the retry policy sets for this query, if any.

Returns:
the retry policy sets specifically for this query or null if no query specific retry policy has been set through setRetryPolicy(com.datastax.driver.core.policies.RetryPolicy) (in which case the Cluster retry policy will apply if necessary).


Copyright © 2013. All Rights Reserved.