public class SimpleStatement extends RegularStatement
RegularStatement
implementation built directly from a query
string.
Use Session.newSimpleStatement(String)
to create a new instance of this
class.
idempotent, NULL_PAYLOAD_VALUE
Modifier | Constructor and Description |
---|---|
protected |
SimpleStatement(String query,
Cluster cluster) |
protected |
SimpleStatement(String query,
Cluster cluster,
Object... values) |
Modifier and Type | Method and Description |
---|---|
String |
getKeyspace()
Returns the keyspace this query operates on.
|
String |
getQueryString()
Returns the query string for this statement.
|
ByteBuffer |
getRoutingKey()
Returns the routing key for the query.
|
ByteBuffer[] |
getValues()
The values to use for this statement.
|
boolean |
hasValues()
Whether or not this statement has values, that is if
getValues
will return null or not. |
SimpleStatement |
setKeyspace(String keyspace)
Sets the keyspace this query operates on.
|
SimpleStatement |
setRoutingKey(ByteBuffer... routingKeyComponents)
Sets the routing key for this query.
|
SimpleStatement |
setRoutingKey(ByteBuffer routingKey)
Sets the routing key for this query.
|
int |
valuesCount()
The number of values for this statement, that is the size of the array
that will be returned by
getValues . |
toString
disableTracing, enableTracing, getConsistencyLevel, getDefaultTimestamp, getFetchSize, getRetryPolicy, getSerialConsistencyLevel, isIdempotent, isTracing, setConsistencyLevel, setDefaultTimestamp, setFetchSize, setIdempotent, setOutgoingPayload, setPagingState, setPagingStateUnsafe, setRetryPolicy, setSerialConsistencyLevel
public String getQueryString()
RegularStatement
getQueryString
in class RegularStatement
public ByteBuffer[] getValues()
Note: Values for a RegularStatement (i.e. if this method does not return
null
) are not supported with the native protocol version 1: you
will get an UnsupportedProtocolVersionException
when submitting
one if version 1 of the protocol is in use (i.e. if you've force version
1 through Cluster.Builder.withProtocolVersion(com.datastax.driver.core.ProtocolVersion)
or you use
Cassandra 1.2).
Note: Calling this method may trigger the underlying Cluster
initialization.
getValues
in class RegularStatement
SimpleStatement(String, Cluster, Object...)
public int valuesCount()
getValues
.public boolean hasValues()
RegularStatement
getValues
will return null
or not.hasValues
in class RegularStatement
false
if RegularStatement.getValues()
returns null
, true
otherwise.public ByteBuffer getRoutingKey()
Unless the routing key has been explicitly set through
setRoutingKey(java.nio.ByteBuffer)
, this method will return null
to
avoid having to parse the query string to retrieve the partition key.
getRoutingKey
in class Statement
setRoutingKey(java.nio.ByteBuffer)
if such a key
was set, null
otherwise.Statement.getRoutingKey()
public SimpleStatement setRoutingKey(ByteBuffer routingKey)
This method allows you to manually provide a routing key for this query. It is thus optional since the routing key is only an hint for token aware load balancing policy but is never mandatory.
If the partition key for the query is composite, use the
setRoutingKey(ByteBuffer...)
method instead to build the
routing key.
routingKey
- the raw (binary) value to use as routing key.SimpleStatement
object.Statement.getRoutingKey()
public String getKeyspace()
Unless the keyspace has been explicitly set through setKeyspace(java.lang.String)
,
this method will return null
to avoid having to parse the query
string.
getKeyspace
in class Statement
setKeyspace(java.lang.String)
if such keyspace was
set, null
otherwise.Statement.getKeyspace()
public SimpleStatement setKeyspace(String keyspace)
This method allows you to manually provide a keyspace for this query. It is thus optional since the value returned by this method is only an hint for token aware load balancing policy but is never mandatory.
Do note that if the query does not use a fully qualified keyspace, then you do not need to set the keyspace through that method as the currently logged in keyspace will be used.
keyspace
- the name of the keyspace this query operates on.SimpleStatement
object.Statement.getKeyspace()
public SimpleStatement setRoutingKey(ByteBuffer... routingKeyComponents)
See setRoutingKey(ByteBuffer)
for more information. This
method is a variant for when the query partition key is composite and
thus the routing key must be built from multiple values.
routingKeyComponents
- the raw (binary) values to compose to obtain
the routing key.SimpleStatement
object.Statement.getRoutingKey()
Copyright © 2012–2015. All rights reserved.