public class DefaultPreparedStatement extends Object implements PreparedStatement
| Modifier and Type | Method and Description |
|---|---|
BoundStatement |
bind()
Creates a new BoundStatement object for this prepared statement.
|
BoundStatement |
bind(Object... values)
Creates a new BoundStatement object and bind its variables to the
provided values.
|
PreparedStatement |
disableTracing()
Convenience method to disable tracing for all bound statements created
from this prepared statement.
|
PreparedStatement |
enableTracing()
Convenience method to enables tracing for all bound statements created
from this prepared statement.
|
CodecRegistry |
getCodecRegistry()
Return the
CodecRegistry instance associated with this prepared statement. |
ConsistencyLevel |
getConsistencyLevel()
Returns the default consistency level set through
PreparedStatement.setConsistencyLevel(com.datastax.driver.core.ConsistencyLevel). |
Map<String,ByteBuffer> |
getIncomingPayload()
Return the incoming payload, that is, the payload that the server
sent back with its
PREPARED response, if any,
or null, if the server did not include any custom payload. |
Map<String,ByteBuffer> |
getOutgoingPayload()
Return the outgoing payload currently associated with this statement.
|
PreparedId |
getPreparedId()
Returns the prepared Id for this statement.
|
String |
getQueryKeyspace()
Returns the keyspace at the time that this prepared statement was prepared,
(that is the one on which this statement applies unless it specified a
keyspace explicitly).
|
String |
getQueryString()
Returns the string of the query that was prepared to yield this
PreparedStatement. |
RetryPolicy |
getRetryPolicy()
Returns the retry policy sets for this prepared statement, if any.
|
ByteBuffer |
getRoutingKey()
Returns the routing key set for this query.
|
ConsistencyLevel |
getSerialConsistencyLevel()
Returns the default serial consistency level set through
PreparedStatement.setSerialConsistencyLevel(com.datastax.driver.core.ConsistencyLevel). |
ColumnDefinitions |
getVariables()
Returns metadata on the bounded variables of this prepared statement.
|
Boolean |
isIdempotent()
Whether this statement is idempotent, i.e.
|
boolean |
isTracing()
Returns whether tracing is enabled for this prepared statement, i.e.
|
PreparedStatement |
setConsistencyLevel(ConsistencyLevel consistency)
Sets a default consistency level for all bound statements
created from this prepared statement.
|
PreparedStatement |
setIdempotent(Boolean idempotent)
Sets whether this statement is idempotent.
|
PreparedStatement |
setOutgoingPayload(Map<String,ByteBuffer> payload)
Associate the given payload with this prepared statement.
|
PreparedStatement |
setRetryPolicy(RetryPolicy policy)
Convenience method to set a default retry policy for the
BoundStatement
created from this prepared statement. |
PreparedStatement |
setRoutingKey(ByteBuffer... routingKeyComponents)
Sets the routing key for this query.
|
PreparedStatement |
setRoutingKey(ByteBuffer routingKey)
Sets the routing key for this prepared statement.
|
PreparedStatement |
setSerialConsistencyLevel(ConsistencyLevel serialConsistency)
Sets a default serial consistency level for all bound statements
created from this prepared statement.
|
public ColumnDefinitions getVariables()
PreparedStatementgetVariables in interface PreparedStatementpublic BoundStatement bind(Object... values)
PreparedStatementvalues cannot be greater than the number of bound
variables, the number of values may be fewer than the number of bound
variables. In that case, the remaining variables will have to be bound
to values by another mean because the resulting BoundStatement
being executable.
This method is a convenience for new BoundStatement(this).bind(...).bind in interface PreparedStatementvalues - the values to bind to the variables of the newly created
BoundStatement.BoundStatement with its variables
bound to values.BoundStatement.bind(java.lang.Object...)public BoundStatement bind()
PreparedStatementBoundStatement.setInt(int, int), BoundStatement.setLong(int, long), ...).bind in interface PreparedStatementBoundStatement.public PreparedStatement setRoutingKey(ByteBuffer routingKey)
PreparedStatementsetRoutingKey in interface PreparedStatementroutingKey - the raw (binary) value to use as routing key.PreparedStatement object.Statement.getRoutingKey(com.datastax.driver.core.ProtocolVersion, com.datastax.driver.core.CodecRegistry),
BoundStatement.getRoutingKey(com.datastax.driver.core.ProtocolVersion, com.datastax.driver.core.CodecRegistry)public PreparedStatement setRoutingKey(ByteBuffer... routingKeyComponents)
PreparedStatementPreparedStatement.setRoutingKey(ByteBuffer) for more information. This
method is a variant for when the query partition key is composite and
the routing key must be built from multiple values.setRoutingKey in interface PreparedStatementroutingKeyComponents - the raw (binary) values to compose to obtain
the routing key.PreparedStatement object.Statement.getRoutingKey(com.datastax.driver.core.ProtocolVersion, com.datastax.driver.core.CodecRegistry)public ByteBuffer getRoutingKey()
PreparedStatementgetRoutingKey in interface PreparedStatementnull if none has been
explicitly set on this PreparedStatement.public PreparedStatement setConsistencyLevel(ConsistencyLevel consistency)
PreparedStatementsetConsistencyLevel in interface PreparedStatementconsistency - the default consistency level to set.PreparedStatement object.public ConsistencyLevel getConsistencyLevel()
PreparedStatementPreparedStatement.setConsistencyLevel(com.datastax.driver.core.ConsistencyLevel).getConsistencyLevel in interface PreparedStatementnull if no
consistency level has been set through this object setConsistencyLevel
method.public PreparedStatement setSerialConsistencyLevel(ConsistencyLevel serialConsistency)
PreparedStatementsetSerialConsistencyLevel in interface PreparedStatementserialConsistency - the default serial consistency level to set.PreparedStatement object.public ConsistencyLevel getSerialConsistencyLevel()
PreparedStatementPreparedStatement.setSerialConsistencyLevel(com.datastax.driver.core.ConsistencyLevel).getSerialConsistencyLevel in interface PreparedStatementnull if no
consistency level has been set through this object setSerialConsistencyLevel
method.public String getQueryString()
PreparedStatementPreparedStatement.
Note that a CQL3 query may be implicitly applied to the current keyspace
(that is, if the keyspace is not explicitly qualified in the query
itself). For prepared queries, the current keyspace used is the one at
the time of the preparation, not the one at execution time. The current
keyspace at the time of the preparation can be retrieved through
PreparedStatement.getQueryKeyspace().getQueryString in interface PreparedStatementPreparedStatement.public String getQueryKeyspace()
PreparedStatementgetQueryKeyspace in interface PreparedStatementnull if no keyspace was set when the query was prepared (which
is possible since keyspaces can be explicitly qualified in queries and
so may not require a current keyspace to be set).public PreparedStatement enableTracing()
PreparedStatementenableTracing in interface PreparedStatementQuery object.public PreparedStatement disableTracing()
PreparedStatementdisableTracing in interface PreparedStatementPreparedStatement object.public boolean isTracing()
PreparedStatementisTracing in interface PreparedStatementtrue if this prepared statement has tracing enabled,
false otherwise.public PreparedStatement setRetryPolicy(RetryPolicy policy)
PreparedStatementBoundStatement
created from this prepared statement.
Note that this method is completely optional. By default, the retry policy
used is the one returned Policies.getRetryPolicy()
in the cluster configuration. This method is only useful if you want
to override this default policy for the BoundStatement created from
this PreparedStatement.
to punctually override the default policy for this request.setRetryPolicy in interface PreparedStatementpolicy - the retry policy to use for this prepared statement.PreparedStatement object.public RetryPolicy getRetryPolicy()
PreparedStatementgetRetryPolicy in interface PreparedStatementnull if none have been set.public PreparedId getPreparedId()
PreparedStatementgetPreparedId in interface PreparedStatementpublic Map<String,ByteBuffer> getIncomingPayload()
PreparedStatementPREPARED response, if any,
or null, if the server did not include any custom payload.
Note that if an incoming payload is present,
and if no outgoing payload has been explicitly set, then each time
a BoundStatement is created (with either PreparedStatement.bind() or PreparedStatement.bind(Object...)),
the resulting BoundStatement will inherit from this value
as its default outgoing payload.
Implementors should return a read-only view of the original map, but even though,
its values would remain inherently mutable.
Callers should take care not to modify the returned map in any way.
This feature is only available with ProtocolVersion.V4 or above; with lower
versions, this method will always return null.getIncomingPayload in interface PreparedStatementnull, if the server did not include any custom payload.public Map<String,ByteBuffer> getOutgoingPayload()
PreparedStatementBoundStatement is
created (with either PreparedStatement.bind() or PreparedStatement.bind(Object...)),
the resulting BoundStatement will inherit from this value
as its default outgoing payload.
Implementors should return a read-only view of the original map, but even though,
its values would remain inherently mutable.
Callers should take care not to modify the returned map in any way.
This feature is only available with ProtocolVersion.V4 or above.getOutgoingPayload in interface PreparedStatementnull if no outgoing payload is setpublic PreparedStatement setOutgoingPayload(Map<String,ByteBuffer> payload)
PreparedStatementBoundStatement is
created (with either PreparedStatement.bind() or PreparedStatement.bind(Object...)),
the resulting BoundStatement will inherit from this value
as its default outgoing payload.
Implementors should make a defensive, thread-safe copy of the given map, but even though,
its values would remain inherently mutable.
Callers should take care not to modify the original map once it is passed to this method.
This feature is only available with ProtocolVersion.V4 or above.
Trying to include custom payloads in requests sent by the driver
under lower protocol versions will result in an
UnsupportedFeatureException
(wrapped in a NoHostAvailableException).setOutgoingPayload in interface PreparedStatementpayload - the outgoing payload to associate with this statement,
or null to clear any previously associated payload.Statement object.public CodecRegistry getCodecRegistry()
PreparedStatementCodecRegistry instance associated with this prepared statement.
Implementations should never return null; instead, they should always return
the CodecRegistry instance registered with the Cluster instance
this prepared statement belongs to.getCodecRegistry in interface PreparedStatementCodecRegistry instance associated with this prepared statement.public PreparedStatement setIdempotent(Boolean idempotent)
Statement.isIdempotent() for more explanations about this property.setIdempotent in interface PreparedStatementidempotent - the new value.IdempotenceAwarePreparedStatement object.public Boolean isIdempotent()
Statement.isIdempotent() for more explanations about this property.
Please note that idempotence will be propagated to all BoundStatements created from this prepared statement.isIdempotent in interface PreparedStatementnull to use
QueryOptions.getDefaultIdempotence().Copyright © 2012–2017. All rights reserved.