public class CqlTemplate extends CassandraAccessor implements CqlOperations
CqlTemplate simplifies the use of Cassandra
and helps to avoid common errors. The template executes the core Cassandra workflow, leaving application code to
provide CQL and result handling. The template executes CQL queries, provides different ways to extract and map
results, and provides Exception translation to the generic, more informative exception hierarchy defined in the
org.springframework.dao package.
For working with POJOs, use the CassandraTemplate.
CqlOperations,
CassandraAccessor| Modifier and Type | Field and Description |
|---|---|
protected static ResultSetExtractor<com.datastax.driver.core.ResultSet> |
RESULT_SET_RETURNING_EXTRACTOR |
protected static Executor |
RUN_RUNNABLE_EXECUTOR |
logger| Constructor and Description |
|---|
CqlTemplate()
Constructs an uninitialized instance of
CqlTemplate. |
CqlTemplate(com.datastax.driver.core.Session session)
Constructs an instance of
CqlTemplate initialized with the given Session. |
| Modifier and Type | Method and Description |
|---|---|
static com.datastax.driver.core.PreparedStatement |
addPreparedStatementOptions(com.datastax.driver.core.PreparedStatement preparedStatement,
QueryOptions queryOptions)
Add common
QueryOptions to Cassandra PreparedStatements. |
static <T extends com.datastax.driver.core.Statement> |
addQueryOptions(T statement,
QueryOptions queryOptions)
Add common
QueryOptions to all types of queries. |
static com.datastax.driver.core.querybuilder.Insert |
addWriteOptions(com.datastax.driver.core.querybuilder.Insert insert,
WriteOptions writeOptions)
Add common
WriteOptions options to Insert CQL statements. |
static com.datastax.driver.core.querybuilder.Update |
addWriteOptions(com.datastax.driver.core.querybuilder.Update update,
WriteOptions writeOptions)
Add common
WriteOptions options to Update CQL statements. |
long |
count(CqlIdentifier tableName)
Counts all rows for given table
|
long |
count(String tableName)
Counts all rows for given table
|
List<RingMember> |
describeRing()
Describe the current Ring.
|
<T> Collection<T> |
describeRing(HostMapper<T> hostMapper)
Describe the current Ring.
|
protected <T> T |
doExecute(SessionCallback<T> callback)
Executes the given command in a Cassandra
Session. |
protected com.datastax.driver.core.ResultSet |
doExecute(com.datastax.driver.core.Statement statement)
Execute a command at the Session Level with optional options
|
protected com.datastax.driver.core.ResultSet |
doExecute(String cql) |
protected com.datastax.driver.core.ResultSet |
doExecute(String cql,
QueryOptions queryOptions) |
protected com.datastax.driver.core.ResultSetFuture |
doExecuteAsync(com.datastax.driver.core.Statement statement) |
protected Cancellable |
doExecuteAsync(com.datastax.driver.core.Statement statement,
AsynchronousQueryListener listener) |
protected Cancellable |
doExecuteAsync(com.datastax.driver.core.Statement statement,
AsynchronousQueryListener listener,
QueryOptions queryOptions) |
protected com.datastax.driver.core.ResultSet |
doExecuteQueryReturnResultSet(com.datastax.driver.core.querybuilder.Select select) |
protected com.datastax.driver.core.ResultSet |
doExecuteQueryReturnResultSet(String query) |
com.datastax.driver.core.ResultSet |
execute(AlterKeyspaceSpecification specification)
Convenience method to convert the given specification to CQL and execute it.
|
com.datastax.driver.core.ResultSet |
execute(AlterTableSpecification specification)
Convenience method to convert the given specification to CQL and execute it.
|
void |
execute(com.datastax.driver.core.querybuilder.Batch batch)
Executes the supplied Batch Query and returns nothing.
|
com.datastax.driver.core.ResultSet |
execute(CreateIndexSpecification specification)
Convenience method to convert the given specification to CQL and execute it.
|
com.datastax.driver.core.ResultSet |
execute(CreateKeyspaceSpecification specification)
Convenience method to convert the given specification to CQL and execute it.
|
com.datastax.driver.core.ResultSet |
execute(CreateTableSpecification specification)
Convenience method to convert the given specification to CQL and execute it.
|
void |
execute(com.datastax.driver.core.querybuilder.Delete delete)
Executes the supplied Delete Query and returns nothing.
|
com.datastax.driver.core.ResultSet |
execute(DropIndexSpecification specification)
Convenience method to convert the given specification to CQL and execute it.
|
com.datastax.driver.core.ResultSet |
execute(DropKeyspaceSpecification specification)
Convenience method to convert the given specification to CQL and execute it.
|
com.datastax.driver.core.ResultSet |
execute(DropTableSpecification specification)
Convenience method to convert the given specification to CQL and execute it.
|
void |
execute(com.datastax.driver.core.querybuilder.Insert insert)
Executes the supplied Insert Query and returns nothing.
|
<T> T |
execute(PreparedStatementCreator preparedStatementCreator,
PreparedStatementCallback<T> preparedStatementCallback)
Uses the provided
PreparedStatementCreator to create a PreparedStatement in the current
Session, then passes that PreparedStatement to the given PreparedStatementCallback. |
<T> T |
execute(SessionCallback<T> sessionCallback)
Executes the supplied
SessionCallback in the current Template Session. |
void |
execute(com.datastax.driver.core.Statement statement)
Executes the supplied Query and returns nothing.
|
void |
execute(String cql)
Executes the supplied CQL Query and returns nothing.
|
<T> T |
execute(String cql,
PreparedStatementCallback<T> callback)
Creates and caches a
PreparedStatement from the given CQL, invokes the PreparedStatementCallback
with that PreparedStatement, then returns the value returned by the PreparedStatementCallback. |
void |
execute(String cql,
QueryOptions options)
Executes the supplied CQL Query and returns nothing.
|
void |
execute(com.datastax.driver.core.querybuilder.Truncate truncate)
Executes the supplied Truncate Query and returns nothing.
|
void |
execute(com.datastax.driver.core.querybuilder.Update update)
Executes the supplied Update Query and returns nothing.
|
com.datastax.driver.core.ResultSetFuture |
executeAsynchronously(com.datastax.driver.core.querybuilder.Batch batch)
Executes the supplied CQL Batch Asynchronously and returns nothing.
|
Cancellable |
executeAsynchronously(com.datastax.driver.core.querybuilder.Batch batch,
AsynchronousQueryListener listener) |
com.datastax.driver.core.ResultSetFuture |
executeAsynchronously(com.datastax.driver.core.querybuilder.Delete delete)
Executes the supplied CQL Delete Asynchronously and returns nothing.
|
Cancellable |
executeAsynchronously(com.datastax.driver.core.querybuilder.Delete delete,
AsynchronousQueryListener listener) |
com.datastax.driver.core.ResultSetFuture |
executeAsynchronously(com.datastax.driver.core.querybuilder.Insert insert)
Executes the supplied CQL Insert Asynchronously and returns nothing.
|
Cancellable |
executeAsynchronously(com.datastax.driver.core.querybuilder.Insert insert,
AsynchronousQueryListener listener) |
com.datastax.driver.core.ResultSetFuture |
executeAsynchronously(com.datastax.driver.core.Statement statement)
Executes the supplied CQL Query Asynchronously and returns nothing.
|
Cancellable |
executeAsynchronously(com.datastax.driver.core.Statement statement,
AsynchronousQueryListener listener)
Executes the supplied CQL Query Asynchronously and returns nothing.
|
Cancellable |
executeAsynchronously(com.datastax.driver.core.Statement statement,
AsynchronousQueryListener listener,
Executor executor)
Executes the supplied CQL Query Asynchronously and returns nothing.
|
Cancellable |
executeAsynchronously(com.datastax.driver.core.Statement statement,
Runnable listener)
Executes the supplied CQL Query Asynchronously and returns nothing.
|
Cancellable |
executeAsynchronously(com.datastax.driver.core.Statement statement,
Runnable listener,
Executor executor)
Executes the supplied CQL Query Asynchronously and returns nothing.
|
com.datastax.driver.core.ResultSetFuture |
executeAsynchronously(String cql)
Executes the supplied Query Asynchronously and returns nothing.
|
Cancellable |
executeAsynchronously(String cql,
AsynchronousQueryListener listener)
Executes the supplied Query Asynchronously and returns nothing.
|
Cancellable |
executeAsynchronously(String cql,
AsynchronousQueryListener listener,
Executor executor)
Executes the supplied Query Asynchronously and returns nothing.
|
com.datastax.driver.core.ResultSetFuture |
executeAsynchronously(String cql,
QueryOptions queryOptions)
Executes the supplied Query Asynchronously and returns nothing.
|
Cancellable |
executeAsynchronously(String cql,
Runnable listener)
Executes the supplied Query Asynchronously and returns nothing.
|
Cancellable |
executeAsynchronously(String cql,
Runnable listener,
Executor executor)
Executes the supplied Query Asynchronously and returns nothing.
|
com.datastax.driver.core.ResultSetFuture |
executeAsynchronously(com.datastax.driver.core.querybuilder.Truncate truncate)
Executes the supplied CQL Truncate Asynchronously and returns nothing.
|
Cancellable |
executeAsynchronously(com.datastax.driver.core.querybuilder.Truncate truncate,
AsynchronousQueryListener listener) |
com.datastax.driver.core.ResultSetFuture |
executeAsynchronously(com.datastax.driver.core.querybuilder.Update update)
Executes the supplied CQL Update Asynchronously and returns nothing.
|
Cancellable |
executeAsynchronously(com.datastax.driver.core.querybuilder.Update update,
AsynchronousQueryListener listener) |
protected Object |
firstColumnToObject(com.datastax.driver.core.Row row) |
protected Set<com.datastax.driver.core.Host> |
getHosts()
Requests the set of hosts in the Cassandra cluster from the current
Session. |
com.datastax.driver.core.ResultSet |
getResultSetUninterruptibly(com.datastax.driver.core.ResultSetFuture resultSetFuture)
Convenient method that delegates to
ResultSetFuture.getUninterruptibly() but translates exceptions if any
are thrown. |
com.datastax.driver.core.ResultSet |
getResultSetUninterruptibly(com.datastax.driver.core.ResultSetFuture resultSetFuture,
long milliseconds)
Convenient method that delegates to
ResultSetFuture.getUninterruptibly() but translates exceptions if any
are thrown. |
com.datastax.driver.core.ResultSet |
getResultSetUninterruptibly(com.datastax.driver.core.ResultSetFuture resultSetFuture,
long timeout,
TimeUnit timeUnit)
Convenient method that delegates to
ResultSetFuture.getUninterruptibly() but translates exceptions if any
are thrown. |
void |
ingest(String cql,
List<List<?>> rows)
This is an operation designed for high performance writes.
|
void |
ingest(String cql,
List<List<?>> rows,
WriteOptions writeOptions)
This is an operation designed for high performance writes.
|
void |
ingest(String cql,
Object[][] rows)
This is an operation designed for high performance writes.
|
void |
ingest(String cql,
Object[][] rows,
WriteOptions writeOptions)
This is an operation designed for high performance writes.
|
void |
ingest(String cql,
RowIterator rowIterator)
This is an operation designed for high performance writes.
|
void |
ingest(String cql,
RowIterator rowIterator,
WriteOptions options)
This is an operation designed for high performance writes.
|
protected String |
logCql(String cql) |
protected String |
logCql(String message,
String cql) |
protected <T extends com.datastax.driver.core.Statement> |
logStatement(T statement) |
void |
process(com.datastax.driver.core.ResultSet resultSet,
RowCallbackHandler rowCallbackHandler)
Processes the ResultSet through the RowCallbackHandler and return nothing.
|
<T> List<T> |
process(com.datastax.driver.core.ResultSet resultSet,
RowMapper<T> rowMapper)
Processes the ResultSet through the RowMapper and returns the List of mapped Rows.
|
<T> List<T> |
processList(com.datastax.driver.core.ResultSet resultSet,
Class<T> elementType)
Process a ResultSet and convert the first column of the results to a List.
|
List<Map<String,Object>> |
processListOfMap(com.datastax.driver.core.ResultSet resultSet)
Process a ResultSet and convert it to a List of Maps with column/value.
|
Map<String,Object> |
processMap(com.datastax.driver.core.ResultSet resultSet)
Process a ResultSet with ONE Row and convert to a Map.
|
<T> T |
processOne(com.datastax.driver.core.ResultSet resultSet,
Class<T> requiredType)
Process a ResultSet, trying to convert the first columns of the first Row to Class
|
<T> T |
processOne(com.datastax.driver.core.ResultSet resultSet,
RowMapper<T> rowMapper)
Process
ResultSet with RowMapper. |
<T> T |
query(PreparedStatementCreator preparedStatementCreator,
PreparedStatementBinder preparedStatementBinder,
ResultSetExtractor<T> resultSetExtractor)
Uses the provided PreparedStatementCreator to prepare a new Session call.
|
<T> T |
query(PreparedStatementCreator preparedStatementCreator,
PreparedStatementBinder preparedStatementBinder,
ResultSetExtractor<T> resultSetExtractor,
QueryOptions queryOptions)
Uses the provided PreparedStatementCreator to prepare a new Session call.
|
void |
query(PreparedStatementCreator preparedStatementCreator,
PreparedStatementBinder preparedStatementBinder,
RowCallbackHandler rowCallbackHandler)
Uses the provided PreparedStatementCreator to prepare a new Session call.
|
void |
query(PreparedStatementCreator preparedStatementCreator,
PreparedStatementBinder preparedStatementBinder,
RowCallbackHandler rowCallbackHandler,
QueryOptions queryOptions)
Uses the provided PreparedStatementCreator to prepare a new Session call.
|
<T> List<T> |
query(PreparedStatementCreator preparedStatementCreator,
PreparedStatementBinder preparedStatementBinder,
RowMapper<T> rowMapper)
Uses the provided PreparedStatementCreator to prepare a new Session call.
|
<T> List<T> |
query(PreparedStatementCreator preparedStatementCreator,
PreparedStatementBinder preparedStatementBinder,
RowMapper<T> rowMapper,
QueryOptions queryOptions)
Uses the provided PreparedStatementCreator to prepare a new Session call.
|
<T> T |
query(PreparedStatementCreator preparedStatementCreator,
ResultSetExtractor<T> resultSetExtractor)
Uses the provided PreparedStatementCreator to prepare a new Session call.
|
<T> T |
query(PreparedStatementCreator preparedStatementCreator,
ResultSetExtractor<T> resultSetExtractor,
QueryOptions queryOptions)
Uses the provided PreparedStatementCreator to prepare a new Session call.
|
void |
query(PreparedStatementCreator preparedStatementCreator,
RowCallbackHandler rowCallbackHandler)
Uses the provided PreparedStatementCreator to prepare a new Session call.
|
void |
query(PreparedStatementCreator preparedStatementCreator,
RowCallbackHandler rowCallbackHandler,
QueryOptions queryOptions)
Uses the provided PreparedStatementCreator to prepare a new Session call.
|
<T> List<T> |
query(PreparedStatementCreator preparedStatementCreator,
RowMapper<T> rowMapper)
Uses the provided PreparedStatementCreator to prepare a new Session call.
|
<T> List<T> |
query(PreparedStatementCreator preparedStatementCreator,
RowMapper<T> rowMapper,
QueryOptions queryOptions)
Uses the provided PreparedStatementCreator to prepare a new Session call.
|
com.datastax.driver.core.ResultSet |
query(com.datastax.driver.core.querybuilder.Select select)
Executes the provided Select query and returns the
ResultSet. |
<T> T |
query(com.datastax.driver.core.querybuilder.Select select,
ResultSetExtractor<T> resultSetExtractor)
Executes the provided Select Query, and extracts the results with the ResultSetExtractor.
|
void |
query(com.datastax.driver.core.querybuilder.Select select,
RowCallbackHandler rowCallbackHandler)
Executes the provided Select Query, and then processes the results with the
RowCallbackHandler. |
<T> List<T> |
query(com.datastax.driver.core.querybuilder.Select select,
RowMapper<T> rowMapper)
Executes the provided Select Query, and maps all Rows returned with the supplied RowMapper.
|
com.datastax.driver.core.ResultSet |
query(String cql)
Executes the provided CQL query and returns the
ResultSet. |
<T> T |
query(String cql,
PreparedStatementBinder preparedStatementBinder,
ResultSetExtractor<T> resultSetExtractor)
Converts the CQL provided into a
CachedPreparedStatementCreator. |
<T> T |
query(String cql,
PreparedStatementBinder preparedStatementBinder,
ResultSetExtractor<T> resultSetExtractor,
QueryOptions queryOptions)
Converts the CQL provided into a
CachedPreparedStatementCreator. |
void |
query(String cql,
PreparedStatementBinder preparedStatementBinder,
RowCallbackHandler rowCallbackHandler)
Converts the CQL provided into a
CachedPreparedStatementCreator. |
void |
query(String cql,
PreparedStatementBinder preparedStatementBinder,
RowCallbackHandler rowCallbackHandler,
QueryOptions queryOptions)
Converts the CQL provided into a
CachedPreparedStatementCreator. |
<T> List<T> |
query(String cql,
PreparedStatementBinder preparedStatementBinder,
RowMapper<T> rowMapper)
Converts the CQL provided into a
CachedPreparedStatementCreator. |
<T> List<T> |
query(String cql,
PreparedStatementBinder preparedStatementBinder,
RowMapper<T> rowMapper,
QueryOptions queryOptions)
Converts the CQL provided into a
CachedPreparedStatementCreator. |
com.datastax.driver.core.ResultSet |
query(String cql,
QueryOptions queryOptions)
Executes the provided CQL query with the given
QueryOptions and returns the ResultSet. |
<T> T |
query(String cql,
ResultSetExtractor<T> resultSetExtractor)
Executes the provided CQL Query, and extracts the results with the ResultSetExtractor.
|
<T> T |
query(String cql,
ResultSetExtractor<T> resultSetExtractor,
QueryOptions queryOptions)
Executes the provided CQL Query, and extracts the results with the ResultSetExtractor.
|
void |
query(String cql,
RowCallbackHandler rowCallbackHandler)
Executes the provided CQL Query, and then processes the results with the
RowCallbackHandler. |
void |
query(String cql,
RowCallbackHandler rowCallbackHandler,
QueryOptions queryOptions)
Executes the provided CQL Query, and then processes the results with the
RowCallbackHandler. |
<T> List<T> |
query(String cql,
RowMapper<T> rowMapper)
Executes the provided CQL Query, and maps all Rows returned with the supplied RowMapper.
|
<T> List<T> |
query(String cql,
RowMapper<T> rowMapper,
QueryOptions queryOptions)
Executes the provided CQL Query, and maps all Rows returned with the supplied RowMapper.
|
com.datastax.driver.core.ResultSetFuture |
queryAsynchronously(com.datastax.driver.core.querybuilder.Select select)
Executes the provided CQL Select and returns the ResultSetFuture for user processing.
|
Cancellable |
queryAsynchronously(com.datastax.driver.core.querybuilder.Select select,
AsynchronousQueryListener listener)
Executes the provided CQL Select with the provided listener.
|
Cancellable |
queryAsynchronously(com.datastax.driver.core.querybuilder.Select select,
AsynchronousQueryListener listener,
Executor executor)
Executes the provided Select Query with the provided listener and executor.
|
Cancellable |
queryAsynchronously(com.datastax.driver.core.querybuilder.Select select,
Runnable listener)
Executes the provided CQL Select with the provided
Runnable, which is started after the query has
completed. |
Cancellable |
queryAsynchronously(com.datastax.driver.core.querybuilder.Select select,
Runnable listener,
Executor executor)
Executes the provided CQL Select with the provided Executor and Runnable implementations.
|
com.datastax.driver.core.ResultSetFuture |
queryAsynchronously(String cql)
Executes the provided CQL Query and returns the ResultSetFuture for user processing.
|
Cancellable |
queryAsynchronously(String cql,
AsynchronousQueryListener listener)
Executes the provided CQL Query with the provided listener.
|
Cancellable |
queryAsynchronously(String cql,
AsynchronousQueryListener listener,
Executor executor)
Executes the provided CQL Query with the provided listener and executor.
|
Cancellable |
queryAsynchronously(String cql,
AsynchronousQueryListener listener,
QueryOptions queryOptions)
Executes the provided CQL Query with the provided Listener and Query Options.
|
Cancellable |
queryAsynchronously(String cql,
AsynchronousQueryListener listener,
QueryOptions queryOptions,
Executor executor)
Executes the provided CQL Query with the provided Listener, Executor and Query Options.
|
com.datastax.driver.core.ResultSetFuture |
queryAsynchronously(String cql,
QueryOptions queryOptions)
Executes the provided CQL Query and returns the ResultSetFuture for user processing.
|
<T> T |
queryAsynchronously(String cql,
ResultSetExtractor<T> resultSetExtractor,
Long timeout,
TimeUnit timeUnit)
Executes the provided CQL Query, and extracts the results with the ResultSetExtractor.
|
<T> T |
queryAsynchronously(String cql,
ResultSetExtractor<T> resultSetExtractor,
Long timeout,
TimeUnit timeUnit,
QueryOptions options)
Executes the provided CQL Query, and extracts the results with the ResultSetExtractor.
|
<T> T |
queryAsynchronously(String cql,
ResultSetFutureExtractor<T> resultSetFutureExtractor) |
<T> T |
queryAsynchronously(String cql,
ResultSetFutureExtractor<T> resultSetFutureExtractor,
QueryOptions queryOptions) |
Cancellable |
queryAsynchronously(String cql,
Runnable listener)
Executes the provided CQL Query with the provided
Runnable, which is started after the query has completed. |
Cancellable |
queryAsynchronously(String cql,
Runnable listener,
Executor executor)
Executes the provided CQL Query with the provided Executor and Runnable implementations.
|
Cancellable |
queryAsynchronously(String cql,
Runnable listener,
QueryOptions queryOptions)
Executes the provided CQL Query with the Runnable implementations using the Query Options.
|
Cancellable |
queryAsynchronously(String cql,
Runnable listener,
QueryOptions queryOptions,
Executor executor)
Executes the provided CQL Query with the provided Executor and Runnable implementations.
|
<T> List<T> |
queryForList(com.datastax.driver.core.querybuilder.Select select,
Class<T> elementType)
Executes the provided Select Query and returns all values in the first column of the Results as a List of the Type
in the second argument.
|
<T> List<T> |
queryForList(String cql,
Class<T> elementType)
Executes the provided CQL and returns all values in the first column of the Results as a List of the Type in the
second argument.
|
<T> Cancellable |
queryForListAsynchronously(com.datastax.driver.core.querybuilder.Select select,
Class<T> requiredType,
QueryForListListener<T> listener)
Executes the provided
Select query asynchronously and returns all values in the first column of the results
as a List of the type in the second argument. |
<T> Cancellable |
queryForListAsynchronously(String select,
Class<T> requiredType,
QueryForListListener<T> listener)
Executes the provided
Select query asynchronously and returns all values in the first column of the results
as a List of the type in the second argument. |
List<Map<String,Object>> |
queryForListOfMap(com.datastax.driver.core.querybuilder.Select select)
Executes the provided Select Query and converts the results to a basic List of Maps.
|
List<Map<String,Object>> |
queryForListOfMap(String cql)
Executes the provided CQL and converts the results to a basic List of Maps.
|
Cancellable |
queryForListOfMapAsynchronously(com.datastax.driver.core.querybuilder.Select select,
QueryForListListener<Map<String,Object>> listener)
|
Cancellable |
queryForListOfMapAsynchronously(String cql,
QueryForListListener<Map<String,Object>> listener)
|
Cancellable |
queryForListOfMapAsynchronously(String cql,
QueryForListListener<Map<String,Object>> listener,
QueryOptions queryOptions)
|
Map<String,Object> |
queryForMap(com.datastax.driver.core.querybuilder.Select select)
Executes the provided Select Query and maps ONE Row to a basic Map of Strings and Objects.
|
Map<String,Object> |
queryForMap(String cql)
Executes the provided CQL Query and maps ONE Row to a basic Map of Strings and Objects.
|
Cancellable |
queryForMapAsynchronously(com.datastax.driver.core.querybuilder.Select select,
QueryForMapListener listener)
Executes the provided
Select query asynchronously and maps the first row to a Map
<String,Object>. |
Cancellable |
queryForMapAsynchronously(String cql,
QueryForMapListener listener)
Executes the provided CQL query asynchronously and maps the first row to a
Map<String,Object>. |
Cancellable |
queryForMapAsynchronously(String cql,
QueryForMapListener listener,
QueryOptions queryOptions)
Executes the provided CQL query asynchronously and maps the first row to a
Map<String,Object>. |
<T> T |
queryForObject(com.datastax.driver.core.querybuilder.Select select,
Class<T> requiredType)
Executes the provided Select query and tries to return the first column of the first Row as a Class
|
<T> T |
queryForObject(com.datastax.driver.core.querybuilder.Select select,
RowMapper<T> rowMapper)
Executes the provided Select Query, and maps ONE Row returned with the supplied RowMapper.
|
<T> T |
queryForObject(String cql,
Class<T> requiredType)
Executes the provided query and tries to return the first column of the first Row as a Class
|
<T> T |
queryForObject(String cql,
RowMapper<T> rowMapper)
Executes the provided CQL Query, and maps ONE Row returned with the supplied RowMapper.
|
<T> Cancellable |
queryForObjectAsynchronously(com.datastax.driver.core.querybuilder.Select select,
Class<T> requiredType,
QueryForObjectListener<T> listener)
Executes the provided
Select query and returns the first column of the first Row as an object of type
T. |
<T> Cancellable |
queryForObjectAsynchronously(com.datastax.driver.core.querybuilder.Select select,
RowMapper<T> rowMapper,
QueryForObjectListener<T> listener)
Executes the provided
Select query, and maps the first row returned with the supplied RowMapper. |
<T> Cancellable |
queryForObjectAsynchronously(String cql,
Class<T> requiredType,
QueryForObjectListener<T> listener)
Executes the provided select CQL query and returns the first column of the first Row as an object of type
T. |
<T> Cancellable |
queryForObjectAsynchronously(String cql,
Class<T> requiredType,
QueryForObjectListener<T> listener,
QueryOptions options)
Executes the provided select CQL query and returns the first column of the first Row as an object of type
T. |
<T> Cancellable |
queryForObjectAsynchronously(String cql,
RowMapper<T> rowMapper,
QueryForObjectListener<T> listener)
Executes the provided string CQL query, and maps the first row returned with the supplied
RowMapper. |
<T> Cancellable |
queryForObjectAsynchronously(String cql,
RowMapper<T> rowMapper,
QueryForObjectListener<T> listener,
QueryOptions options)
Executes the provided string CQL query, and maps the first row returned with the supplied
RowMapper. |
protected long |
selectCount(com.datastax.driver.core.querybuilder.Select select) |
protected Map<String,Object> |
toMap(com.datastax.driver.core.Row row) |
protected RuntimeException |
translateExceptionIfPossible(Throwable t)
|
protected static RuntimeException |
translateExceptionIfPossible(Throwable t,
PersistenceExceptionTranslator exceptionTranslator)
Tries to convert the given
RuntimeException into a DataAccessException but returns the original
exception if the conversation failed. |
void |
truncate(CqlIdentifier tableName)
Delete all rows in the table
|
void |
truncate(String tableName)
Delete all rows in the table
|
afterPropertiesSet, getExceptionTranslator, getSession, logDebug, setExceptionTranslator, setSessionclone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, waitgetSessionprotected static final Executor RUN_RUNNABLE_EXECUTOR
protected static final ResultSetExtractor<com.datastax.driver.core.ResultSet> RESULT_SET_RETURNING_EXTRACTOR
public CqlTemplate()
CqlTemplate. A Cassandra Session is required before use.CqlTemplate(Session)public CqlTemplate(com.datastax.driver.core.Session session)
CqlTemplate initialized with the given Session.session - Cassandra Session used by this template to perform CQL operations. Must not be
null.Session,
CassandraAccessor.setSession(Session)protected <T extends com.datastax.driver.core.Statement> T logStatement(T statement)
public static com.datastax.driver.core.PreparedStatement addPreparedStatementOptions(com.datastax.driver.core.PreparedStatement preparedStatement,
QueryOptions queryOptions)
QueryOptions to Cassandra PreparedStatements.preparedStatement - the Cassandra PreparedStatement to execute.queryOptions - query options (e.g. consistency level) to add to the Cassandra PreparedStatement.public static <T extends com.datastax.driver.core.Statement> T addQueryOptions(T statement,
QueryOptions queryOptions)
QueryOptions to all types of queries.statement - CQL Statement to execute.queryOptions - query options (e.g. consistency level) to add to the CQL statement.Statement.public static com.datastax.driver.core.querybuilder.Insert addWriteOptions(com.datastax.driver.core.querybuilder.Insert insert,
WriteOptions writeOptions)
WriteOptions options to Insert CQL statements.insert - Insert CQL statement to execute.writeOptions - write options (e.g. consistency level) to add to the CQL statement.Insert.public static com.datastax.driver.core.querybuilder.Update addWriteOptions(com.datastax.driver.core.querybuilder.Update update,
WriteOptions writeOptions)
WriteOptions options to Update CQL statements.update - Update CQL statement to execute.writeOptions - write options (e.g. consistency level) to add to the CQL statement.Update.protected <T> T doExecute(SessionCallback<T> callback)
Session.T - Class type of the callback return value.callback - SessionCallback to execute in the context of a Cassandra Session.protected com.datastax.driver.core.ResultSet doExecuteQueryReturnResultSet(String query)
protected com.datastax.driver.core.ResultSet doExecuteQueryReturnResultSet(com.datastax.driver.core.querybuilder.Select select)
public <T> T execute(SessionCallback<T> sessionCallback)
CqlOperationsSessionCallback in the current Template Session. The implementation of
SessionCallback can decide whether or not to execute() or executeAsync() the operation.execute in interface CqlOperationspublic void execute(String cql)
CqlOperationsexecute in interface CqlOperationspublic void execute(String cql, QueryOptions options)
CqlOperationsexecute in interface CqlOperationsoptions - may be nullpublic void execute(com.datastax.driver.core.Statement statement)
CqlOperationsexecute in interface CqlOperationsstatement - The Statement to executepublic com.datastax.driver.core.ResultSetFuture queryAsynchronously(String cql)
CqlOperationsqueryAsynchronously in interface CqlOperationscql - The Querypublic <T> T queryAsynchronously(String cql, ResultSetExtractor<T> resultSetExtractor, Long timeout, TimeUnit timeUnit)
CqlOperationsqueryAsynchronously in interface CqlOperationscql - The QueryresultSetExtractor - The implementation for extracting the ResultSettimeout - Time to wait for resultstimeUnit - Time unit to wait for resultspublic <T> T queryAsynchronously(String cql, ResultSetExtractor<T> resultSetExtractor, Long timeout, TimeUnit timeUnit, QueryOptions options)
CqlOperationsqueryAsynchronously in interface CqlOperationscql - The QueryresultSetExtractor - The implementation for extracting the ResultSettimeout - Time to wait for resultstimeUnit - Time unit to wait for resultsoptions - Query Optionspublic com.datastax.driver.core.ResultSetFuture queryAsynchronously(String cql, QueryOptions queryOptions)
CqlOperationsqueryAsynchronously in interface CqlOperationscql - The QueryqueryOptions - Query Optionspublic Cancellable queryAsynchronously(String cql, Runnable listener)
CqlOperationsRunnable, which is started after the query has completed.
A more useful method than this one is CqlOperations.queryAsynchronously(String, AsynchronousQueryListener), where you're
given the ResultSetFuture after the query has been executed.queryAsynchronously in interface CqlOperationscql - The Querylistener - Runnable listener for handling the query in a separate threadCancellable that can be used to cancel the query.CqlOperations.queryAsynchronously(String, AsynchronousQueryListener)public Cancellable queryAsynchronously(String cql, AsynchronousQueryListener listener)
CqlOperationsRunnable. The AsynchronousQueryListener gives you access to the ResultSetFuture once the
query is completed for optimal flexibility.queryAsynchronously in interface CqlOperationscql - The Querylistener - AsynchronousQueryListener for handling the query's ResultSetFuture in a separate
threadCancellable that can be used to cancel the query.public Cancellable queryAsynchronously(String cql, Runnable listener, QueryOptions queryOptions)
CqlOperationsqueryAsynchronously in interface CqlOperationscql - The Querylistener - Runnable Listener for handling the query in a separate threadqueryOptions - Query OptionCancellable that can be used to cancel the query.public Cancellable queryAsynchronously(String cql, AsynchronousQueryListener listener, QueryOptions queryOptions)
CqlOperationsAsynchronousQueryListener gives you access to the
ResultSetFuture once the query is completed for optimal flexibility.queryAsynchronously in interface CqlOperationscql - The Querylistener - Runnable Listener for handling the query in a separate threadqueryOptions - Query OptionCancellable that can be used to cancel the query.public Cancellable queryAsynchronously(String cql, Runnable listener, Executor executor)
CqlOperationsqueryAsynchronously in interface CqlOperationscql - The Querylistener - Runnable Listener for handling the query in a separate threadexecutor - To execute the Runnable ListenerCancellable that can be used to cancel the query.public Cancellable queryAsynchronously(String cql, AsynchronousQueryListener listener, Executor executor)
CqlOperationsAsynchronousQueryListener gives you access to the ResultSetFuture
once the query is completed for optimal flexibility.queryAsynchronously in interface CqlOperationscql - The Querylistener - Runnable Listener for handling the query in a separate threadexecutor - To execute the Runnable ListenerCancellable that can be used to cancel the query.public Cancellable queryAsynchronously(String cql, Runnable listener, QueryOptions queryOptions, Executor executor)
CqlOperationsqueryAsynchronously in interface CqlOperationscql - The Querylistener - Runnable Listener for handling the query in a separate threadqueryOptions - Query Optionexecutor - To execute the Runnable ListenerCancellable that can be used to cancel the query.public Cancellable queryAsynchronously(String cql, AsynchronousQueryListener listener, QueryOptions queryOptions, Executor executor)
CqlOperationsAsynchronousQueryListener gives you access to the
ResultSetFuture once the query is completed for optimal flexibility.queryAsynchronously in interface CqlOperationsCancellable that can be used to cancel the query.public <T> T queryAsynchronously(String cql, ResultSetFutureExtractor<T> resultSetFutureExtractor)
public <T> T queryAsynchronously(String cql, ResultSetFutureExtractor<T> resultSetFutureExtractor, QueryOptions queryOptions)
public <T> T query(String cql, ResultSetExtractor<T> resultSetExtractor)
CqlOperationsquery in interface CqlOperationscql - The QueryresultSetExtractor - The implementation for extracting the ResultSetpublic <T> T query(String cql, ResultSetExtractor<T> resultSetExtractor, QueryOptions queryOptions)
CqlOperationsquery in interface CqlOperationscql - The QueryresultSetExtractor - The implementation for extracting the ResultSetqueryOptions - Query Optionspublic void query(String cql, RowCallbackHandler rowCallbackHandler)
CqlOperationsRowCallbackHandler.query in interface CqlOperationscql - The QueryrowCallbackHandler - The implementation for processing the rows returned.public void query(String cql, RowCallbackHandler rowCallbackHandler, QueryOptions queryOptions)
CqlOperationsRowCallbackHandler.query in interface CqlOperationscql - The QueryrowCallbackHandler - The implementation for processing the rows returned.queryOptions - Query Options Objectpublic <T> List<T> query(String cql, RowMapper<T> rowMapper, QueryOptions queryOptions)
CqlOperationsquery in interface CqlOperationscql - The QueryrowMapper - The implementation for mapping all rowsqueryOptions - Query Options Objectpublic com.datastax.driver.core.ResultSet query(String cql)
CqlOperationsResultSet.query in interface CqlOperationscql - The queryResultSetpublic com.datastax.driver.core.ResultSet query(String cql, QueryOptions queryOptions)
CqlOperationsQueryOptions and returns the ResultSet.query in interface CqlOperationscql - The queryqueryOptions - The QueryOptions; may be null.ResultSetpublic <T> List<T> query(String cql, RowMapper<T> rowMapper)
CqlOperationsquery in interface CqlOperationscql - The QueryrowMapper - The implementation for mapping all rowspublic List<Map<String,Object>> queryForListOfMap(String cql)
CqlOperationsqueryForListOfMap in interface CqlOperationscql - The Querypublic <T> List<T> queryForList(String cql, Class<T> elementType)
CqlOperationsqueryForList in interface CqlOperationscql - The QueryelementType - Type to cast the data values topublic Map<String,Object> queryForMap(String cql)
CqlOperationsqueryForMap in interface CqlOperationscql - The Querypublic <T> T queryForObject(String cql, Class<T> requiredType)
CqlOperationsqueryForObject in interface CqlOperationscql - The QueryrequiredType - Valid Class that Cassandra Data Types can be converted to.public <T> T queryForObject(String cql, RowMapper<T> rowMapper)
CqlOperationsThis expects only ONE row to be returned. More than one Row will cause an Exception to be thrown.
queryForObject in interface CqlOperationscql - The QueryrowMapper - The implementation for convert the Row to protected com.datastax.driver.core.ResultSet doExecute(String cql)
protected com.datastax.driver.core.ResultSet doExecute(String cql, QueryOptions queryOptions)
protected com.datastax.driver.core.ResultSet doExecute(com.datastax.driver.core.Statement statement)
statement - The query to execute.protected com.datastax.driver.core.ResultSetFuture doExecuteAsync(com.datastax.driver.core.Statement statement)
protected Cancellable doExecuteAsync(com.datastax.driver.core.Statement statement, AsynchronousQueryListener listener)
protected Cancellable doExecuteAsync(com.datastax.driver.core.Statement statement, AsynchronousQueryListener listener, QueryOptions queryOptions)
protected Object firstColumnToObject(com.datastax.driver.core.Row row)
public List<RingMember> describeRing()
CqlOperationsRingMemberHostMapper to provide the basics of the
Cassandra Ring topology.describeRing in interface CqlOperationsprotected Set<com.datastax.driver.core.Host> getHosts()
Session.public <T> Collection<T> describeRing(HostMapper<T> hostMapper)
CqlOperationsHostMapper implementation to process the
lists of hosts returned by the Cassandra Cluster Metadata.describeRing in interface CqlOperationshostMapper - The implementation to use for host mapping.public com.datastax.driver.core.ResultSetFuture executeAsynchronously(String cql)
CqlOperationsexecuteAsynchronously in interface CqlOperationscql - The CQL String to executeResultSetFuture that can be used to cancel the query.public com.datastax.driver.core.ResultSetFuture executeAsynchronously(String cql, QueryOptions queryOptions)
CqlOperationsexecuteAsynchronously in interface CqlOperationscql - The CQL String to executequeryOptions - The QueryOptions to use. Only applies to cql statements that can use QueryOptions.ResultSetFuture that can be used to cancel the query.public Cancellable executeAsynchronously(String cql, Runnable listener)
CqlOperationsexecuteAsynchronously in interface CqlOperationscql - The CQL String to executelistener - The Runnable to register with the ResultSetFutureCancellable that can be used to cancel the query.for Readspublic Cancellable executeAsynchronously(String cql, Runnable listener, Executor executor)
CqlOperationsexecuteAsynchronously in interface CqlOperationscql - The CQL String to executelistener - The Runnable to register with the ResultSetFutureexecutor - The Executor to regsiter with the ResultSetFutureCancellable that can be used to cancel the query.for Readspublic Cancellable executeAsynchronously(String cql, AsynchronousQueryListener listener)
CqlOperationsexecuteAsynchronously in interface CqlOperationscql - The CQL String to executelistener - The AsynchronousQueryListener to register with the ResultSetFutureCancellable that can be used to cancel the query.for Readspublic Cancellable executeAsynchronously(String cql, AsynchronousQueryListener listener, Executor executor)
CqlOperationsexecuteAsynchronously in interface CqlOperationscql - The CQL String to executelistener - The AsynchronousQueryListener to register with the ResultSetFutureexecutor - The Executor to regsiter with the ResultSetFutureCancellable that can be used to cancel the query.for Readspublic com.datastax.driver.core.ResultSetFuture executeAsynchronously(com.datastax.driver.core.Statement statement)
CqlOperationsexecuteAsynchronously in interface CqlOperationsstatement - The Statement to executeResultSetFuture that can be used to cancel the query.public Cancellable executeAsynchronously(com.datastax.driver.core.Statement statement, Runnable listener)
CqlOperationsexecuteAsynchronously in interface CqlOperationsstatement - The Statement to executeCancellable that can be used to cancel the query.public Cancellable executeAsynchronously(com.datastax.driver.core.Statement statement, AsynchronousQueryListener listener)
CqlOperationsexecuteAsynchronously in interface CqlOperationsstatement - The Statement to executeCancellable that can be used to cancel the query.public Cancellable executeAsynchronously(com.datastax.driver.core.Statement statement, Runnable listener, Executor executor)
CqlOperationsexecuteAsynchronously in interface CqlOperationsstatement - The Statement to executeCancellable that can be used to cancel the query.public Cancellable executeAsynchronously(com.datastax.driver.core.Statement statement, AsynchronousQueryListener listener, Executor executor)
CqlOperationsexecuteAsynchronously in interface CqlOperationsstatement - The Statement to executeCancellable that can be used to cancel the query.public void process(com.datastax.driver.core.ResultSet resultSet,
RowCallbackHandler rowCallbackHandler)
CqlOperationsprocess in interface CqlOperationsresultSet - Results to processrowCallbackHandler - RowCallbackHandler with the processing implementationpublic <T> List<T> process(com.datastax.driver.core.ResultSet resultSet, RowMapper<T> rowMapper)
CqlOperationsprocess in interface CqlOperationsresultSet - Results to processrowMapper - RowMapper with the processing implementationpublic <T> T processOne(com.datastax.driver.core.ResultSet resultSet,
RowMapper<T> rowMapper)
CqlOperationsResultSet with RowMapper. This method is used internally to the template for core
operations, but is made available through this interface in the event you have a ResultSet to process. The
ResultSet could come from a ResultSetFuture after an asynchronous query.processOne in interface CqlOperationsresultSet - ResultSet to process, must not be null.rowMapper - RowMapper used to process the single row of the result set, must not be null.public <T> T processOne(com.datastax.driver.core.ResultSet resultSet,
Class<T> requiredType)
CqlOperationsprocessOne in interface CqlOperationspublic Map<String,Object> processMap(com.datastax.driver.core.ResultSet resultSet)
CqlOperationsprocessMap in interface CqlOperationspublic <T> List<T> processList(com.datastax.driver.core.ResultSet resultSet, Class<T> elementType)
CqlOperationsprocessList in interface CqlOperationspublic List<Map<String,Object>> processListOfMap(com.datastax.driver.core.ResultSet resultSet)
CqlOperationsprocessListOfMap in interface CqlOperationsprotected RuntimeException translateExceptionIfPossible(Throwable t)
e - the Exception to translate.RuntimeException.protected static RuntimeException translateExceptionIfPossible(Throwable t, PersistenceExceptionTranslator exceptionTranslator)
RuntimeException into a DataAccessException but returns the original
exception if the conversation failed. Thus allows safe re-throwing of the return value.e - the exception to translateexceptionTranslator - the PersistenceExceptionTranslator to be used for translationpublic <T> T execute(PreparedStatementCreator preparedStatementCreator, PreparedStatementCallback<T> preparedStatementCallback)
CqlOperationsPreparedStatementCreator to create a PreparedStatement in the current
Session, then passes that PreparedStatement to the given PreparedStatementCallback.execute in interface CqlOperationspreparedStatementCreator - The PreparedStatementCreatorpreparedStatementCallback - The callback that receives the PreparedStatementPreparedStatementCallbackpublic <T> T execute(String cql, PreparedStatementCallback<T> callback)
CqlOperationsPreparedStatement from the given CQL, invokes the PreparedStatementCallback
with that PreparedStatement, then returns the value returned by the PreparedStatementCallback.execute in interface CqlOperationscql - The CQL statement from which to create and cache a PreparedStatementcallback - The callback that is given the PreparedStatementPreparedStatementCallbackpublic <T> T query(PreparedStatementCreator preparedStatementCreator, ResultSetExtractor<T> resultSetExtractor)
CqlOperationsquery in interface CqlOperationspreparedStatementCreator - The implementation to create the PreparedStatementresultSetExtractor - Implementation for extracting from the ResultSetpublic <T> T query(PreparedStatementCreator preparedStatementCreator, ResultSetExtractor<T> resultSetExtractor, QueryOptions queryOptions)
CqlOperationsquery in interface CqlOperationspreparedStatementCreator - The implementation to create the PreparedStatementresultSetExtractor - Implementation for extracting from the ResultSetqueryOptions - The Query Options Objectpublic void query(PreparedStatementCreator preparedStatementCreator, RowCallbackHandler rowCallbackHandler)
CqlOperationsquery in interface CqlOperationspreparedStatementCreator - The implementation to create the PreparedStatementrowCallbackHandler - The implementation to process Resultspublic void query(PreparedStatementCreator preparedStatementCreator, RowCallbackHandler rowCallbackHandler, QueryOptions queryOptions)
CqlOperationsquery in interface CqlOperationspreparedStatementCreator - The implementation to create the PreparedStatementrowCallbackHandler - The implementation to process ResultsqueryOptions - The Query Options Objectpublic <T> List<T> query(PreparedStatementCreator preparedStatementCreator, RowMapper<T> rowMapper)
CqlOperationsquery in interface CqlOperationspreparedStatementCreator - The implementation to create the PreparedStatementrowMapper - The implementation for mapping each Row returned.public <T> List<T> query(PreparedStatementCreator preparedStatementCreator, RowMapper<T> rowMapper, QueryOptions queryOptions)
CqlOperationsquery in interface CqlOperationspreparedStatementCreator - The implementation to create the PreparedStatementrowMapper - The implementation for mapping each Row returned.queryOptions - The Query Options Objectpublic <T> T query(String cql, PreparedStatementBinder preparedStatementBinder, ResultSetExtractor<T> resultSetExtractor)
CqlOperationsCachedPreparedStatementCreator. Then, the PreparedStatementBinder will
bind its values to the bind variables in the provided CQL String. The results of the PreparedStatement are
processed with the ResultSetExtractor implementation provided by the Application Code. The can return any object,
including a List of Objects to support the ResultSet processing.query in interface CqlOperationscql - The Query to PreparepreparedStatementBinder - The Binding implementationresultSetExtractor - The implementation for extracting the results of the query.public <T> T query(String cql, PreparedStatementBinder preparedStatementBinder, ResultSetExtractor<T> resultSetExtractor, QueryOptions queryOptions)
CqlOperationsCachedPreparedStatementCreator. Then, the PreparedStatementBinder will
bind its values to the bind variables in the provided CQL String. The results of the PreparedStatement are
processed with the ResultSetExtractor implementation provided by the Application Code. The can return any object,
including a List of Objects to support the ResultSet processing.query in interface CqlOperationscql - The Query to PreparepreparedStatementBinder - The Binding implementationresultSetExtractor - The implementation for extracting the results of the query.queryOptions - The Query Options to apply to the PreparedStatementpublic void query(String cql, PreparedStatementBinder preparedStatementBinder, RowCallbackHandler rowCallbackHandler)
CqlOperationsCachedPreparedStatementCreator. Then, the PreparedStatementBinder will
bind its values to the bind variables in the provided CQL String. The results of the PreparedStatement are
processed with the RowCallbackHandler implementation provided and nothing is returned.query in interface CqlOperationscql - The Query to PreparepreparedStatementBinder - The Binding implementationrowCallbackHandler - The RowCallbackHandler for processing the ResultSetpublic void query(String cql, PreparedStatementBinder preparedStatementBinder, RowCallbackHandler rowCallbackHandler, QueryOptions queryOptions)
CqlOperationsCachedPreparedStatementCreator. Then, the PreparedStatementBinder will
bind its values to the bind variables in the provided CQL String. The results of the PreparedStatement are
processed with the RowCallbackHandler implementation provided and nothing is returned.query in interface CqlOperationscql - The Query to PreparepreparedStatementBinder - The Binding implementationrowCallbackHandler - The RowCallbackHandler for processing the ResultSetqueryOptions - The Query Options Objectpublic <T> List<T> query(String cql, PreparedStatementBinder preparedStatementBinder, RowMapper<T> rowMapper)
CqlOperationsCachedPreparedStatementCreator. Then, the PreparedStatementBinder will
bind its values to the bind variables in the provided CQL String. The results of the PreparedStatement are
processed with the RowMapper implementation provided and a List is returned with elements of Type query in interface CqlOperationscql - The Query to PreparepreparedStatementBinder - The Binding implementationrowMapper - The implementation for Mapping a Row to Type public <T> List<T> query(String cql, PreparedStatementBinder preparedStatementBinder, RowMapper<T> rowMapper, QueryOptions queryOptions)
CqlOperationsCachedPreparedStatementCreator. Then, the PreparedStatementBinder will
bind its values to the bind variables in the provided CQL String. The results of the PreparedStatement are
processed with the RowMapper implementation provided and a List is returned with elements of Type query in interface CqlOperationscql - The Query to PreparepreparedStatementBinder - The Binding implementationrowMapper - The implementation for Mapping a Row to Type queryOptions - The Query Options Objectpublic void ingest(String cql, RowIterator rowIterator, WriteOptions options)
CqlOperationsThis is used internally by the other ingest() methods, but can be used if you want to write your own RowIterator. The Object[] length returned by the next() implementation must match the number of bind variables in the CQL.
ingest in interface CqlOperationscql - The CQLrowIterator - Implementation to provide the Object[] to be bound to the CQL.options - The Query Options Objectpublic void ingest(String cql, RowIterator rowIterator)
CqlOperationsThis is used internally by the other ingest() methods, but can be used if you want to write your own RowIterator. The Object[] length returned by the next() implementation must match the number of bind variables in the CQL.
ingest in interface CqlOperationscql - The CQLrowIterator - Implementation to provide the Object[] to be bound to the CQL.public void ingest(String cql, List<List<?>> rows)
CqlOperationsPreparedStatement
once, then all row values are bound to that PreparedStatement and executed against the Session.
The lengths of the nested Lists must not be less than the number of bind variables in the CQL.
ingest in interface CqlOperationscql - The CQLrows - The data to bind to the CQL statementpublic void ingest(String cql, List<List<?>> rows, WriteOptions writeOptions)
CqlOperationsThe List> length must match the number of bind variables in the CQL.
ingest in interface CqlOperationscql - The CQLrows - List of List> with data to bind to the CQL.writeOptions - The Query Options Objectpublic void ingest(String cql, Object[][] rows)
CqlOperationsPreparedStatement
once, then all row values are bound to that PreparedStatement and executed against the Session.
The lengths of the nested object arrays must not be less than the number of bind variables in the CQL.
ingest in interface CqlOperationscql - The CQLrows - The data to bind to the CQL statementpublic void ingest(String cql, Object[][] rows, WriteOptions writeOptions)
CqlOperationsPreparedStatement
once, then all row values are bound to that PreparedStatement and executed against the Session.
The lengths of the nested object arrays must not be less than the number of bind variables in the CQL.
ingest in interface CqlOperationscql - The CQLrows - The data to bind to the CQL statementwriteOptions - The Query Options Objectpublic void truncate(String tableName)
CqlOperationstruncate in interface CqlOperationspublic void truncate(CqlIdentifier tableName)
CqlOperationstruncate in interface CqlOperationspublic <T> T query(PreparedStatementCreator preparedStatementCreator, PreparedStatementBinder preparedStatementBinder, ResultSetExtractor<T> resultSetExtractor)
CqlOperationsquery in interface CqlOperationspreparedStatementCreator - The implementation to create the PreparedStatementpreparedStatementBinder - The implementation to bind variables to valuesresultSetExtractor - Implementation for extracting from the ResultSetpublic <T> T query(PreparedStatementCreator preparedStatementCreator, PreparedStatementBinder preparedStatementBinder, ResultSetExtractor<T> resultSetExtractor, QueryOptions queryOptions)
CqlOperationsquery in interface CqlOperationspreparedStatementCreator - The implementation to create the PreparedStatementpreparedStatementBinder - The implementation to bind variables to valuesresultSetExtractor - Implementation for extracting from the ResultSetqueryOptions - The Query Options Objectpublic void query(PreparedStatementCreator preparedStatementCreator, PreparedStatementBinder preparedStatementBinder, RowCallbackHandler rowCallbackHandler, QueryOptions queryOptions)
CqlOperationsquery in interface CqlOperationspreparedStatementCreator - The implementation to create the PreparedStatementpreparedStatementBinder - The implementation to bind variables to valuesrowCallbackHandler - The implementation to process ResultsqueryOptions - The Query Options Objectpublic void query(PreparedStatementCreator preparedStatementCreator, PreparedStatementBinder preparedStatementBinder, RowCallbackHandler rowCallbackHandler)
CqlOperationsquery in interface CqlOperationspreparedStatementCreator - The implementation to create the PreparedStatementpreparedStatementBinder - The implementation to bind variables to valuesrowCallbackHandler - The implementation to process Resultspublic <T> List<T> query(PreparedStatementCreator preparedStatementCreator, PreparedStatementBinder preparedStatementBinder, RowMapper<T> rowMapper, QueryOptions queryOptions)
CqlOperationsquery in interface CqlOperationspreparedStatementCreator - The implementation to create the PreparedStatementpreparedStatementBinder - The implementation to bind variables to valuesrowMapper - The implementation for mapping each Row returned.queryOptions - The Query Options Objectpublic <T> List<T> query(PreparedStatementCreator preparedStatementCreator, PreparedStatementBinder preparedStatementBinder, RowMapper<T> rowMapper)
CqlOperationsquery in interface CqlOperationspreparedStatementCreator - The implementation to create the PreparedStatementpreparedStatementBinder - The implementation to bind variables to valuesrowMapper - The implementation for mapping each Row returned.public com.datastax.driver.core.ResultSet execute(AlterKeyspaceSpecification specification)
CqlOperationsexecute in interface CqlOperationsspecification - The specification to execute; must not be null.public com.datastax.driver.core.ResultSet execute(CreateKeyspaceSpecification specification)
CqlOperationsexecute in interface CqlOperationsspecification - The specification to execute; must not be null.public com.datastax.driver.core.ResultSet execute(DropKeyspaceSpecification specification)
CqlOperationsexecute in interface CqlOperationsspecification - The specification to execute; must not be null.public com.datastax.driver.core.ResultSet execute(AlterTableSpecification specification)
CqlOperationsexecute in interface CqlOperationsspecification - The specification to execute; must not be null.public com.datastax.driver.core.ResultSet execute(CreateTableSpecification specification)
CqlOperationsexecute in interface CqlOperationsspecification - The specification to execute; must not be null.public com.datastax.driver.core.ResultSet execute(DropTableSpecification specification)
CqlOperationsexecute in interface CqlOperationsspecification - The specification to execute; must not be null.public com.datastax.driver.core.ResultSet execute(CreateIndexSpecification specification)
CqlOperationsexecute in interface CqlOperationsspecification - The specification to execute; must not be null.public com.datastax.driver.core.ResultSet execute(DropIndexSpecification specification)
CqlOperationsexecute in interface CqlOperationsspecification - The specification to execute; must not be null.public void execute(com.datastax.driver.core.querybuilder.Batch batch)
CqlOperationsexecute in interface CqlOperationspublic void execute(com.datastax.driver.core.querybuilder.Delete delete)
CqlOperationsexecute in interface CqlOperationspublic void execute(com.datastax.driver.core.querybuilder.Insert insert)
CqlOperationsexecute in interface CqlOperationspublic void execute(com.datastax.driver.core.querybuilder.Truncate truncate)
CqlOperationsexecute in interface CqlOperationspublic void execute(com.datastax.driver.core.querybuilder.Update update)
CqlOperationsexecute in interface CqlOperationspublic long count(String tableName)
CqlOperationscount in interface CqlOperationspublic long count(CqlIdentifier tableName)
CqlOperationscount in interface CqlOperationsprotected long selectCount(com.datastax.driver.core.querybuilder.Select select)
public com.datastax.driver.core.ResultSetFuture executeAsynchronously(com.datastax.driver.core.querybuilder.Batch batch)
CqlOperationsexecuteAsynchronously in interface CqlOperationsResultSetFuture that can be used to cancel the query.public com.datastax.driver.core.ResultSetFuture executeAsynchronously(com.datastax.driver.core.querybuilder.Delete delete)
CqlOperationsexecuteAsynchronously in interface CqlOperationsResultSetFuture that can be used to cancel the query.public com.datastax.driver.core.ResultSetFuture executeAsynchronously(com.datastax.driver.core.querybuilder.Insert insert)
CqlOperationsexecuteAsynchronously in interface CqlOperationsResultSetFuture that can be used to cancel the query.public com.datastax.driver.core.ResultSetFuture executeAsynchronously(com.datastax.driver.core.querybuilder.Truncate truncate)
CqlOperationsexecuteAsynchronously in interface CqlOperationsResultSetFuture that can be used to cancel the query.public com.datastax.driver.core.ResultSetFuture executeAsynchronously(com.datastax.driver.core.querybuilder.Update update)
CqlOperationsexecuteAsynchronously in interface CqlOperationsResultSetFuture that can be used to cancel the query.public Cancellable executeAsynchronously(com.datastax.driver.core.querybuilder.Batch batch, AsynchronousQueryListener listener)
executeAsynchronously in interface CqlOperationspublic Cancellable executeAsynchronously(com.datastax.driver.core.querybuilder.Delete delete, AsynchronousQueryListener listener)
executeAsynchronously in interface CqlOperationspublic Cancellable executeAsynchronously(com.datastax.driver.core.querybuilder.Insert insert, AsynchronousQueryListener listener)
executeAsynchronously in interface CqlOperationspublic Cancellable executeAsynchronously(com.datastax.driver.core.querybuilder.Truncate truncate, AsynchronousQueryListener listener)
executeAsynchronously in interface CqlOperationspublic Cancellable executeAsynchronously(com.datastax.driver.core.querybuilder.Update update, AsynchronousQueryListener listener)
executeAsynchronously in interface CqlOperationspublic com.datastax.driver.core.ResultSetFuture queryAsynchronously(com.datastax.driver.core.querybuilder.Select select)
CqlOperationsqueryAsynchronously in interface CqlOperationspublic Cancellable queryAsynchronously(com.datastax.driver.core.querybuilder.Select select, AsynchronousQueryListener listener)
CqlOperationsRunnable. The AsynchronousQueryListener gives you access to the ResultSetFuture once the
query is completed for optimal flexibility.queryAsynchronously in interface CqlOperationsselect - The Selectlistener - AsynchronousQueryListener for handling the query's ResultSetFuture in a separate
threadCancellable that can be used to cancel the query.public Cancellable queryAsynchronously(com.datastax.driver.core.querybuilder.Select select, AsynchronousQueryListener listener, Executor executor)
CqlOperationsAsynchronousQueryListener gives you access to the ResultSetFuture
once the query is completed for optimal flexibility.queryAsynchronously in interface CqlOperationsselect - The Select Querylistener - Runnable Listener for handling the query in a separate threadexecutor - To execute the Runnable ListenerCancellable that can be used to cancel the query.public Cancellable queryAsynchronously(com.datastax.driver.core.querybuilder.Select select, Runnable listener)
CqlOperationsRunnable, which is started after the query has
completed.
A more useful method than this one is CqlOperations.queryAsynchronously(Select, AsynchronousQueryListener), where you're
given the ResultSetFuture after the query has been executed.queryAsynchronously in interface CqlOperationsselect - The Select Querylistener - Runnable listener for handling the query in a separate threadCancellable that can be used to cancel the query.CqlOperations.queryAsynchronously(Select, AsynchronousQueryListener)public Cancellable queryAsynchronously(com.datastax.driver.core.querybuilder.Select select, Runnable listener, Executor executor)
CqlOperationsqueryAsynchronously in interface CqlOperationsselect - The Select Querylistener - Runnable Listener for handling the query in a separate threadexecutor - To execute the Runnable ListenerCancellable that can be used to cancel the query.public com.datastax.driver.core.ResultSet query(com.datastax.driver.core.querybuilder.Select select)
CqlOperationsResultSet.query in interface CqlOperationsselect - The Select QueryResultSetpublic <T> T query(com.datastax.driver.core.querybuilder.Select select,
ResultSetExtractor<T> resultSetExtractor)
CqlOperationsquery in interface CqlOperationsselect - The SelectQueryresultSetExtractor - The implementation for extracting the ResultSetpublic void query(com.datastax.driver.core.querybuilder.Select select,
RowCallbackHandler rowCallbackHandler)
CqlOperationsRowCallbackHandler.query in interface CqlOperationsselect - The Select QueryrowCallbackHandler - The implementation for processing the rows returned.public <T> List<T> query(com.datastax.driver.core.querybuilder.Select select, RowMapper<T> rowMapper)
CqlOperationsquery in interface CqlOperationsselect - The Select QueryrowMapper - The implementation for mapping all rowspublic <T> T queryForObject(com.datastax.driver.core.querybuilder.Select select,
RowMapper<T> rowMapper)
CqlOperationsThis expects only ONE row to be returned. More than one Row will cause an Exception to be thrown.
queryForObject in interface CqlOperationsselect - The Select QueryrowMapper - The implementation for convert the Row to public <T> T queryForObject(com.datastax.driver.core.querybuilder.Select select,
Class<T> requiredType)
CqlOperationsqueryForObject in interface CqlOperationsselect - The Select QueryrequiredType - Valid Class that Cassandra Data Types can be converted to.public Map<String,Object> queryForMap(com.datastax.driver.core.querybuilder.Select select)
CqlOperationsqueryForMap in interface CqlOperationsselect - The Select Querypublic <T> List<T> queryForList(com.datastax.driver.core.querybuilder.Select select, Class<T> elementType)
CqlOperationsqueryForList in interface CqlOperationsselect - The Select QueryelementType - Type to cast the data values topublic List<Map<String,Object>> queryForListOfMap(com.datastax.driver.core.querybuilder.Select select)
CqlOperationsqueryForListOfMap in interface CqlOperationsselect - The Select Querypublic <T> Cancellable queryForListAsynchronously(com.datastax.driver.core.querybuilder.Select select, Class<T> requiredType, QueryForListListener<T> listener)
CqlOperationsSelect query asynchronously and returns all values in the first column of the results
as a List of the type in the second argument.queryForListAsynchronously in interface CqlOperationsselect - The Select queryrequiredType - The type to cast the data values tolistener - The listener to receive the results asynchronously. Must not be null.Cancellable to cancel the query if necessarypublic <T> Cancellable queryForListAsynchronously(String select, Class<T> requiredType, QueryForListListener<T> listener)
CqlOperationsSelect query asynchronously and returns all values in the first column of the results
as a List of the type in the second argument.queryForListAsynchronously in interface CqlOperationsselect - The select query CQLrequiredType - The type to cast the data values tolistener - The listener to receive the results asynchronously. Must not be null.Cancellable to cancel the query if necessarypublic Cancellable queryForListOfMapAsynchronously(com.datastax.driver.core.querybuilder.Select select, QueryForListListener<Map<String,Object>> listener)
CqlOperationsSelect query and converts the results to a List of Maps. Each element
in the List represents a row returned from the query. Each row's column(s) are put into a Map as
values keyed by column name.queryForListOfMapAsynchronously in interface CqlOperationsselect - The Select query. Must not be null.listener - The listener that will receive the results upon query completion. Must not be null.Cancellable that can be used to cancel the query. Must not be null.public Cancellable queryForListOfMapAsynchronously(String cql, QueryForListListener<Map<String,Object>> listener)
CqlOperationsList of Maps. Each element in
the List represents a row returned from the query. Each row's column(s) are put into a Map as
values keyed by column name.queryForListOfMapAsynchronously in interface CqlOperationslistener - The listener that will receive the results upon query completion. Must not be null.Cancellable that can be used to cancel the query. Must not be null.public Cancellable queryForListOfMapAsynchronously(String cql, QueryForListListener<Map<String,Object>> listener, QueryOptions queryOptions)
CqlOperationsList of Maps. Each element in
the List represents a row returned from the query. Each row's column(s) are put into a Map as
values keyed by column name.queryForListOfMapAsynchronously in interface CqlOperationslistener - The listener that will receive the results upon query completion. Must not be null.queryOptions - The QueryOptions to use. May be null.Cancellable that can be used to cancel the query. Must not be null.public Cancellable queryForMapAsynchronously(String cql, QueryForMapListener listener)
CqlOperationsMap<String,Object>.
Additional rows are ignored.queryForMapAsynchronously in interface CqlOperationscql - The select query CQL. Must not be null or blank.listener - The QueryForMapListener that will recieve the results upon query completion. Must not be
null.Cancellable that can be used to cancel the query if necessary. Must not be null.public Cancellable queryForMapAsynchronously(String cql, QueryForMapListener listener, QueryOptions queryOptions)
CqlOperationsMap<String,Object>.
Additional rows are ignored.queryForMapAsynchronously in interface CqlOperationscql - The select query CQL. Must not be null or blank.listener - The QueryForMapListener that will recieve the results upon query completion. Must not be
null.queryOptions - The QueryOptions to use. May be null.Cancellable that can be used to cancel the query if necessary. Must not be null.public Cancellable queryForMapAsynchronously(com.datastax.driver.core.querybuilder.Select select, QueryForMapListener listener)
CqlOperationsSelect query asynchronously and maps the first row to a Map
<String,Object>. Additional rows are ignored.queryForMapAsynchronously in interface CqlOperationslistener - The QueryForMapListener that will recieve the results upon query completion. Must not be
null.Cancellable that can be used to cancel the query if necessary. Must not be null.public <T> Cancellable queryForObjectAsynchronously(com.datastax.driver.core.querybuilder.Select select, Class<T> requiredType, QueryForObjectListener<T> listener)
CqlOperationsSelect query and returns the first column of the first Row as an object of type
T.queryForObjectAsynchronously in interface CqlOperationsselect - The Select queryrequiredType - Type that Cassandra data types can be converted to.Cancellable that can be used to cancel the query if necessary.public <T> Cancellable queryForObjectAsynchronously(String cql, Class<T> requiredType, QueryForObjectListener<T> listener)
CqlOperationsT.queryForObjectAsynchronously in interface CqlOperationscql - The select query CQL. Must not be null or blank.requiredType - The type to convert the first column of the first row to. Must not be null.Cancellable that can be used to cancel the query if necessary. Must not be null.public <T> Cancellable queryForObjectAsynchronously(String cql, Class<T> requiredType, QueryForObjectListener<T> listener, QueryOptions options)
CqlOperationsT.queryForObjectAsynchronously in interface CqlOperationscql - The select query CQL. Must not be null or blank.requiredType - The type to convert the first column of the first row to. Must not be null.options - The QueryOptions to use. May be null.Cancellable that can be used to cancel the query if necessary. Must not be null.public <T> Cancellable queryForObjectAsynchronously(String cql, RowMapper<T> rowMapper, QueryForObjectListener<T> listener)
CqlOperationsRowMapper.queryForObjectAsynchronously in interface CqlOperationscql - The string query CQL.rowMapper - The RowMapper to convert the row into an object of type T.listener - The listener that receives the results upon completion.Cancellable that can be used to cancel the query.public <T> Cancellable queryForObjectAsynchronously(String cql, RowMapper<T> rowMapper, QueryForObjectListener<T> listener, QueryOptions options)
CqlOperationsRowMapper.queryForObjectAsynchronously in interface CqlOperationscql - The string query CQL.rowMapper - The RowMapper to convert the row into an object of type T.listener - The listener that receives the results upon completion.options - The QueryOptions to use. May be null.Cancellable that can be used to cancel the query.public <T> Cancellable queryForObjectAsynchronously(com.datastax.driver.core.querybuilder.Select select, RowMapper<T> rowMapper, QueryForObjectListener<T> listener)
CqlOperationsSelect query, and maps the first row returned with the supplied RowMapper.queryForObjectAsynchronously in interface CqlOperationsselect - The Select query to execute.rowMapper - The RowMapper to convert the row into an object of type T.listener - The listener that receives the results upon completion.Cancellable that can be used to cancel the query.public com.datastax.driver.core.ResultSet getResultSetUninterruptibly(com.datastax.driver.core.ResultSetFuture resultSetFuture)
CqlOperationsResultSetFuture.getUninterruptibly() but translates exceptions if any
are thrown.getResultSetUninterruptibly in interface CqlOperationsresultSetFuture - The ResultSetFuture from which to get the ResultSet.ResultSetpublic com.datastax.driver.core.ResultSet getResultSetUninterruptibly(com.datastax.driver.core.ResultSetFuture resultSetFuture,
long milliseconds)
CqlOperationsResultSetFuture.getUninterruptibly() but translates exceptions if any
are thrown.getResultSetUninterruptibly in interface CqlOperationsresultSetFuture - The ResultSetFuture from which to get the ResultSet.ResultSetpublic com.datastax.driver.core.ResultSet getResultSetUninterruptibly(com.datastax.driver.core.ResultSetFuture resultSetFuture,
long timeout,
TimeUnit timeUnit)
CqlOperationsResultSetFuture.getUninterruptibly() but translates exceptions if any
are thrown.getResultSetUninterruptibly in interface CqlOperationsresultSetFuture - The ResultSetFuture from which to get the ResultSet.timeout - The timeout to wait. A nonpositive value means wait indefinitely.timeUnit - The TimeUnit of the timeout.ResultSetCopyright © 2011–2019 Pivotal Software, Inc.. All rights reserved.