public class ReactiveCqlTemplate extends ReactiveCassandraAccessor implements ReactiveCqlOperations
ReactiveResultSets and
catching DriverException exceptions and translating them to the generic, more informative exception hierarchy
defined in the org.springframework.dao package.
Code using this class need only implement callback interfaces, giving them a clearly defined contract. The
PreparedStatementCreator callback interface creates a prepared statement given a Connection, providing CQL
and any necessary parameters. The ResultSetExtractor interface extracts values from a
ReactiveResultSet. See also PreparedStatementBinder and RowMapper for two popular alternative
callback interfaces.
Can be used within a service implementation via direct instantiation with a ReactiveSessionFactory reference,
or get prepared in an application context and given to services as bean reference. Note: The
ReactiveSessionFactory should always be configured as a bean in the application context, in the first case
given to the service directly, in the second case to the prepared template.
Because this class is parameterizable by the callback interfaces and the
PersistenceExceptionTranslator interface, there should be no need to subclass
it.
All CQL operations performed by this class are logged at debug level, using "org.springframework.data.cassandra.core.cql.ReactiveCqlTemplate" as log category.
NOTE: An instance of this class is thread-safe once configured.
PreparedStatementCreator,
PreparedStatementBinder,
PreparedStatementCallback,
ResultSetExtractor,
RowCallbackHandler,
RowMapper,
PersistenceExceptionTranslatorlogger| Constructor and Description |
|---|
ReactiveCqlTemplate()
Construct a new ReactiveCqlTemplate Note: The {@link ReactiveSessionFactory} has to be set before using the
instance.
|
ReactiveCqlTemplate(ReactiveSession reactiveSession)
Construct a new
ReactiveCqlTemplate, given a ReactiveSession. |
ReactiveCqlTemplate(ReactiveSessionFactory reactiveSessionFactory)
Construct a new
ReactiveCqlTemplate, given a ReactiveSessionFactory to obtain
ReactiveSessions from. |
| Modifier and Type | Method and Description |
|---|---|
protected com.datastax.oss.driver.api.core.cql.Statement<?> |
applyStatementSettings(com.datastax.oss.driver.api.core.cql.Statement<?> statement)
Prepare the given CQL Statement applying statement settings such as page size and consistency level.
|
protected <T> reactor.core.publisher.Flux<T> |
createFlux(ReactiveSessionCallback<T> callback)
Create a reusable
Flux given a ReactiveSessionCallback without exception translation. |
protected <T> reactor.core.publisher.Flux<T> |
createFlux(com.datastax.oss.driver.api.core.cql.Statement<?> statement,
ReactiveStatementCallback<T> callback)
Create a reusable
Flux given a ReactiveStatementCallback without exception translation. |
protected <T> reactor.core.publisher.Mono<T> |
createMono(com.datastax.oss.driver.api.core.cql.Statement<?> statement,
ReactiveStatementCallback<T> callback)
Create a reusable
Mono given a ReactiveStatementCallback without exception translation. |
reactor.core.publisher.Flux<Boolean> |
execute(org.reactivestreams.Publisher<String> statementPublisher)
Issue multiple CQL statements from a CQL statement
Publisher. |
reactor.core.publisher.Mono<Boolean> |
execute(ReactivePreparedStatementCreator psc)
Issue a single CQL execute operation (such as an insert, update or delete statement) using a
ReactivePreparedStatementCreator to provide CQL and any required parameters. |
<T> reactor.core.publisher.Flux<T> |
execute(ReactivePreparedStatementCreator psc,
ReactivePreparedStatementCallback<T> action)
Execute a CQL data access operation, implemented as callback action working on a CQL
PreparedStatement. |
<T> reactor.core.publisher.Flux<T> |
execute(ReactiveSessionCallback<T> action)
Execute a CQL data access operation, implemented as callback action working on a
ReactiveSession. |
reactor.core.publisher.Mono<Boolean> |
execute(com.datastax.oss.driver.api.core.cql.Statement<?> statement)
Issue a single CQL execute, typically a DDL statement, insert, update or delete statement.
|
reactor.core.publisher.Mono<Boolean> |
execute(String cql)
Issue a single CQL execute, typically a DDL statement, insert, update or delete statement.
|
reactor.core.publisher.Mono<Boolean> |
execute(String cql,
Object... args)
Issue a single CQL operation (such as an insert, update or delete statement) via a prepared statement, binding the
given arguments.
|
reactor.core.publisher.Mono<Boolean> |
execute(String cql,
PreparedStatementBinder psb)
Issue an statement using a
PreparedStatementBinder to set bind parameters, with given CQL. |
reactor.core.publisher.Flux<Boolean> |
execute(String cql,
org.reactivestreams.Publisher<Object[]> args)
Issue a single CQL operation (such as an insert, update or delete statement) via a prepared statement, binding the
given arguments.
|
<T> reactor.core.publisher.Flux<T> |
execute(String cql,
ReactivePreparedStatementCallback<T> action)
Execute a CQL data access operation, implemented as callback action working on a CQL
PreparedStatement. |
protected RowMapper<Map<String,Object>> |
getColumnMapRowMapper()
Create a new RowMapper for reading columns as key-value pairs.
|
com.datastax.oss.driver.api.core.ConsistencyLevel |
getConsistencyLevel() |
ExecutionProfileResolver |
getExecutionProfileResolver() |
int |
getFetchSize()
Deprecated.
since 3.0, use
getPageSize(). |
com.datastax.oss.driver.api.core.CqlIdentifier |
getKeyspace() |
int |
getPageSize() |
com.datastax.oss.driver.api.core.ConsistencyLevel |
getSerialConsistencyLevel() |
protected <T> RowMapper<T> |
getSingleColumnRowMapper(Class<T> requiredType)
Create a new RowMapper for reading result objects from a single column.
|
protected PreparedStatementBinder |
newArgPreparedStatementBinder(Object[] args)
Create a new arg-based PreparedStatementSetter using the args passed in.
|
protected ReactivePreparedStatementCreator |
newReactivePreparedStatementCreator(String cql)
Create a new CQL-based
ReactivePreparedStatementCreator using the CQL passed in. |
<T> reactor.core.publisher.Flux<T> |
query(ReactivePreparedStatementCreator psc,
PreparedStatementBinder preparedStatementBinder,
ReactiveResultSetExtractor<T> rse)
Query using a prepared statement, reading the
ReactiveResultSet with a ReactiveResultSetExtractor. |
<T> reactor.core.publisher.Flux<T> |
query(ReactivePreparedStatementCreator psc,
PreparedStatementBinder psb,
RowMapper<T> rowMapper)
Query using a prepared statement and a
PreparedStatementBinder implementation that knows how to bind values
to the query, mapping each row to a Java object via a RowMapper. |
<T> reactor.core.publisher.Flux<T> |
query(ReactivePreparedStatementCreator psc,
ReactiveResultSetExtractor<T> rse)
Query using a prepared statement, reading the
ReactiveResultSet with a ReactiveResultSetExtractor. |
<T> reactor.core.publisher.Flux<T> |
query(ReactivePreparedStatementCreator psc,
RowMapper<T> rowMapper)
Query using a prepared statement, mapping each row to a Java object via a
RowMapper. |
<T> reactor.core.publisher.Flux<T> |
query(com.datastax.oss.driver.api.core.cql.Statement<?> statement,
ReactiveResultSetExtractor<T> rse)
Execute a query given static CQL, reading the
ReactiveResultSet with a ReactiveResultSetExtractor. |
<T> reactor.core.publisher.Flux<T> |
query(com.datastax.oss.driver.api.core.cql.Statement<?> statement,
RowMapper<T> rowMapper)
Execute a query given static CQL, mapping each row to a Java object via a
RowMapper. |
<T> reactor.core.publisher.Flux<T> |
query(String cql,
PreparedStatementBinder psb,
ReactiveResultSetExtractor<T> rse)
Query using a prepared statement, reading the
ReactiveResultSet with a ReactiveResultSetExtractor. |
<T> reactor.core.publisher.Flux<T> |
query(String cql,
PreparedStatementBinder psb,
RowMapper<T> rowMapper)
Query given CQL to create a prepared statement from CQL and a
PreparedStatementBinder implementation that
knows how to bind values to the query, mapping each row to a Java object via a RowMapper. |
<T> reactor.core.publisher.Flux<T> |
query(String cql,
ReactiveResultSetExtractor<T> resultSetExtractor)
Execute a query given static CQL, reading the
ReactiveResultSet with a ReactiveResultSetExtractor. |
<T> reactor.core.publisher.Flux<T> |
query(String cql,
ReactiveResultSetExtractor<T> rse,
Object... args)
Query given CQL to create a prepared statement from CQL and a list of arguments to bind to the query, reading the
ReactiveResultSet with a ReactiveResultSetExtractor. |
<T> reactor.core.publisher.Flux<T> |
query(String cql,
RowMapper<T> rowMapper)
Execute a query given static CQL, mapping each row to a Java object via a
RowMapper. |
<T> reactor.core.publisher.Flux<T> |
query(String cql,
RowMapper<T> rowMapper,
Object... args)
Query given CQL to create a prepared statement from CQL and a list of arguments to bind to the query, mapping each
row to a Java object via a
RowMapper. |
reactor.core.publisher.Flux<Map<String,Object>> |
queryForFlux(com.datastax.oss.driver.api.core.cql.Statement<?> statement)
Execute a query for a result
Flux, given static CQL. |
<T> reactor.core.publisher.Flux<T> |
queryForFlux(com.datastax.oss.driver.api.core.cql.Statement<?> statement,
Class<T> elementType)
Execute a query for a result
Flux, given static CQL. |
reactor.core.publisher.Flux<Map<String,Object>> |
queryForFlux(String cql)
Execute a query for a result
Flux, given static CQL. |
<T> reactor.core.publisher.Flux<T> |
queryForFlux(String cql,
Class<T> elementType)
Execute a query for a result
Flux, given static CQL. |
<T> reactor.core.publisher.Flux<T> |
queryForFlux(String cql,
Class<T> elementType,
Object... args)
Query given CQL to create a prepared statement from CQL and a list of arguments to bind to the query, expecting a
result
Flux. |
reactor.core.publisher.Flux<Map<String,Object>> |
queryForFlux(String cql,
Object... args)
Query given CQL to create a prepared statement from CQL and a list of arguments to bind to the query, expecting a
result
Flux. |
reactor.core.publisher.Mono<Map<String,Object>> |
queryForMap(com.datastax.oss.driver.api.core.cql.Statement<?> statement)
Execute a query for a result Map, given static CQL.
|
reactor.core.publisher.Mono<Map<String,Object>> |
queryForMap(String cql)
Execute a query for a result Map, given static CQL.
|
reactor.core.publisher.Mono<Map<String,Object>> |
queryForMap(String cql,
Object... args)
Query given CQL to create a prepared statement from CQL and a list of arguments to bind to the query, expecting a
result Map.
|
<T> reactor.core.publisher.Mono<T> |
queryForObject(com.datastax.oss.driver.api.core.cql.Statement<?> statement,
Class<T> requiredType)
Execute a query for a result object, given static CQL.
|
<T> reactor.core.publisher.Mono<T> |
queryForObject(com.datastax.oss.driver.api.core.cql.Statement<?> statement,
RowMapper<T> rowMapper)
Execute a query given static CQL, mapping a single result row to a Java object via a
RowMapper. |
<T> reactor.core.publisher.Mono<T> |
queryForObject(String cql,
Class<T> requiredType)
Execute a query for a result object, given static CQL.
|
<T> reactor.core.publisher.Mono<T> |
queryForObject(String cql,
Class<T> requiredType,
Object... args)
Query given CQL to create a prepared statement from CQL and a list of arguments to bind to the query, expecting a
result object.
|
<T> reactor.core.publisher.Mono<T> |
queryForObject(String cql,
RowMapper<T> rowMapper)
Execute a query given static CQL, mapping a single result row to a Java object via a
RowMapper. |
<T> reactor.core.publisher.Mono<T> |
queryForObject(String cql,
RowMapper<T> rowMapper,
Object... args)
Query given CQL to create a prepared statement from CQL and a list of arguments to bind to the query, mapping a
single result row to a Java object via a
RowMapper. |
reactor.core.publisher.Mono<ReactiveResultSet> |
queryForResultSet(com.datastax.oss.driver.api.core.cql.Statement<?> statement)
Execute a query for a ResultSet, given static CQL.
|
reactor.core.publisher.Mono<ReactiveResultSet> |
queryForResultSet(String cql)
Execute a query for a ResultSet, given static CQL.
|
reactor.core.publisher.Mono<ReactiveResultSet> |
queryForResultSet(String cql,
Object... args)
Query given CQL to create a prepared statement from CQL and a list of arguments to bind to the query, expecting a
ResultSet.
|
reactor.core.publisher.Flux<com.datastax.oss.driver.api.core.cql.Row> |
queryForRows(com.datastax.oss.driver.api.core.cql.Statement<?> statement)
Execute a query for Rows, given static CQL.
|
reactor.core.publisher.Flux<com.datastax.oss.driver.api.core.cql.Row> |
queryForRows(String cql)
Execute a query for Rows, given static CQL.
|
reactor.core.publisher.Flux<com.datastax.oss.driver.api.core.cql.Row> |
queryForRows(String cql,
Object... args)
Query given CQL to create a prepared statement from CQL and a list of arguments to bind to the query, expecting
Rows.
|
void |
setConsistencyLevel(com.datastax.oss.driver.api.core.ConsistencyLevel consistencyLevel)
Set the consistency level for this
ReactiveCqlTemplate. |
void |
setExecutionProfile(String profileName)
Set the driver execution profile for this template.
|
void |
setExecutionProfileResolver(ExecutionProfileResolver executionProfileResolver)
Set the
ExecutionProfileResolver for this template. |
void |
setFetchSize(int fetchSize)
Deprecated.
since 3.0, use
setPageSize(int) |
void |
setKeyspace(com.datastax.oss.driver.api.core.CqlIdentifier keyspace)
Set the
keyspace to be applied on statement-level for this template. |
void |
setPageSize(int fetchSize)
Set the page size for this template.
|
void |
setSerialConsistencyLevel(com.datastax.oss.driver.api.core.ConsistencyLevel consistencyLevel)
Set the serial consistency level for this template.
|
protected Function<Throwable,Throwable> |
translateException(String task,
String cql)
Exception translation
Function intended for Mono#otherwise(Function) usage. |
afterPropertiesSet, getExceptionTranslator, getSessionFactory, setExceptionTranslator, setSessionFactory, toCql, translate, translateExceptionIfPossiblepublic ReactiveCqlTemplate()
public ReactiveCqlTemplate(ReactiveSession reactiveSession)
ReactiveCqlTemplate, given a ReactiveSession.reactiveSession - the ReactiveSession, must not be null.public ReactiveCqlTemplate(ReactiveSessionFactory reactiveSessionFactory)
ReactiveCqlTemplate, given a ReactiveSessionFactory to obtain
ReactiveSessions from.reactiveSessionFactory - the ReactiveSessionFactory to obtain ReactiveSessions from, must not
be null.public void setConsistencyLevel(@Nullable com.datastax.oss.driver.api.core.ConsistencyLevel consistencyLevel)
ReactiveCqlTemplate. Consistency level defines the number of nodes
involved into query processing. Relaxed consistency level settings use fewer nodes but eventual consistency is more
likely to occur while a higher consistency level involves more nodes to obtain results with a higher consistency
guarantee.Statement.setConsistencyLevel(ConsistencyLevel),
RetryPolicy@Nullable public com.datastax.oss.driver.api.core.ConsistencyLevel getConsistencyLevel()
ConsistencyLevel specified for this ReactiveCqlTemplate.public void setExecutionProfile(String profileName)
Statement.setExecutionProfileName(String),
ExecutionProfileResolverpublic void setExecutionProfileResolver(ExecutionProfileResolver executionProfileResolver)
ExecutionProfileResolver for this template.DriverExecutionProfile,
ExecutionProfileResolverpublic ExecutionProfileResolver getExecutionProfileResolver()
ExecutionProfileResolver specified for this ReactiveCqlTemplate.@Deprecated public void setFetchSize(int fetchSize)
setPageSize(int)StatementBuilder.setPageSize(int)@Deprecated public int getFetchSize()
getPageSize().public void setKeyspace(com.datastax.oss.driver.api.core.CqlIdentifier keyspace)
keyspace to be applied on statement-level for this template. If not set, the default
CqlSession keyspace will be used.keyspace - the keyspace to apply, must not be null.SimpleStatement.setKeyspace(CqlIdentifier),
BatchStatement.setKeyspace(CqlIdentifier)@Nullable public com.datastax.oss.driver.api.core.CqlIdentifier getKeyspace()
keyspace to be applied on statement-level for this template.public void setPageSize(int fetchSize)
StatementBuilder.setPageSize(int)public int getPageSize()
public void setSerialConsistencyLevel(@Nullable com.datastax.oss.driver.api.core.ConsistencyLevel consistencyLevel)
Statement.setSerialConsistencyLevel(ConsistencyLevel),
ConsistencyLevel@Nullable public com.datastax.oss.driver.api.core.ConsistencyLevel getSerialConsistencyLevel()
ConsistencyLevel specified for this template.public <T> reactor.core.publisher.Flux<T> execute(ReactiveSessionCallback<T> action) throws DataAccessException
ReactiveCqlOperationsReactiveSession. This allows for implementing arbitrary data access
operations, within Spring's managed CQL environment: that is, converting CQL
DriverExceptions into Spring's DataAccessException hierarchy.
The callback action can return a result object, for example a domain object or a collection of domain objects.
execute in interface ReactiveCqlOperationsaction - the callback object that specifies the action.DataAccessException - if there is any problem executing the query.public reactor.core.publisher.Mono<Boolean> execute(String cql) throws DataAccessException
ReactiveCqlOperationsexecute in interface ReactiveCqlOperationscql - static CQL to execute, must not be empty or null.DataAccessException - if there is any problem executing the query.public <T> reactor.core.publisher.Flux<T> query(String cql, ReactiveResultSetExtractor<T> resultSetExtractor) throws DataAccessException
ReactiveCqlOperationsReactiveResultSet with a ReactiveResultSetExtractor.
Uses a CQL Statement, not a PreparedStatement. If you want to execute a static query with a
PreparedStatement, use the overloaded query method with null as argument array.
query in interface ReactiveCqlOperationscql - static CQL to execute, must not be empty or null.resultSetExtractor - object that will extract all rows of results, must not be null.DataAccessException - if there is any problem executing the query.ReactiveCqlOperations.query(String, ReactiveResultSetExtractor, Object...)public <T> reactor.core.publisher.Flux<T> query(String cql, RowMapper<T> rowMapper) throws DataAccessException
ReactiveCqlOperationsRowMapper.
Uses a CQL Statement, not a PreparedStatement. If you want to execute a static query with a
PreparedStatement, use the overloaded query method with null as argument array.
query in interface ReactiveCqlOperationscql - static CQL to execute, must not be empty or null.rowMapper - object that will map one object per row, must not be null.Flux, containing mapped objects.DataAccessException - if there is any problem executing the query.ReactiveCqlOperations.query(String, RowMapper, Object[])public <T> reactor.core.publisher.Mono<T> queryForObject(String cql, RowMapper<T> rowMapper) throws DataAccessException
ReactiveCqlOperationsRowMapper.
Uses a CQL Statement, not a PreparedStatement. If you want to execute a static query with a
PreparedStatement, use the overloaded ReactiveCqlOperations.queryForObject(String, RowMapper, Object...) method with
null as argument array.
queryForObject in interface ReactiveCqlOperationscql - static CQL to execute, must not be empty or null.rowMapper - object that will map one object per row, must not be null.IncorrectResultSizeDataAccessException - if the query does not return exactly one row.DataAccessException - if there is any problem executing the query.ReactiveCqlOperations.queryForObject(String, RowMapper, Object[])public <T> reactor.core.publisher.Mono<T> queryForObject(String cql, Class<T> requiredType) throws DataAccessException
ReactiveCqlOperations
Uses a CQL Statement, not a PreparedStatement. If you want to execute a static query with a
PreparedStatement, use the overloaded ReactiveCqlOperations.queryForObject(String, Class, Object...) method with
null as argument array.
This method is useful for running static CQL with a known outcome. The query is expected to be a single row/single column query; the returned result will be directly mapped to the corresponding object type.
queryForObject in interface ReactiveCqlOperationscql - static CQL to execute, must not be empty or null.requiredType - the type that the result object is expected to match, must not be null.Mono.empty() in case of CQL NULL.IncorrectResultSizeDataAccessException - if the query does not return exactly one row, or does not return
exactly one column in that row.DataAccessException - if there is any problem executing the query.ReactiveCqlOperations.queryForObject(String, Class, Object[])public reactor.core.publisher.Mono<Map<String,Object>> queryForMap(String cql) throws DataAccessException
ReactiveCqlOperations
Uses a CQL Statement, not a PreparedStatement. If you want to execute a static query with a
PreparedStatement, use the overloaded ReactiveCqlOperations.queryForMap(String, Object...) method with null
as argument array.
The query is expected to be a single row query; the result row will be mapped to a Map (one entry for each column, using the column name as the key).
queryForMap in interface ReactiveCqlOperationscql - static CQL to execute, must not be empty or null.IncorrectResultSizeDataAccessException - if the query does not return exactly one row.DataAccessException - if there is any problem executing the query.ReactiveCqlOperations.queryForMap(String, Object[]),
ColumnMapRowMapperpublic <T> reactor.core.publisher.Flux<T> queryForFlux(String cql, Class<T> elementType) throws DataAccessException
ReactiveCqlOperationsFlux, given static CQL.
Uses a CQL Statement, not a PreparedStatement. If you want to execute a static query with a
PreparedStatement, use the overloaded queryForFlux method with null as argument array.
The results will be mapped to a Flux (one item for each row) of result objects, each of them matching the
specified element type.
queryForFlux in interface ReactiveCqlOperationscql - static CQL to execute, must not be empty or null.elementType - the required type of element in the result Flux (for example, Integer.class),
must not be null.Flux of objects that match the specified element type.DataAccessException - if there is any problem executing the query.ReactiveCqlOperations.queryForFlux(String, Class, Object[]),
SingleColumnRowMapperpublic reactor.core.publisher.Flux<Map<String,Object>> queryForFlux(String cql) throws DataAccessException
ReactiveCqlOperationsFlux, given static CQL.
Uses a CQL Statement, not a PreparedStatement. If you want to execute a static query with a
PreparedStatement, use the overloaded queryForFlux method with null as argument array.
The results will be mapped to a Flux (one item for each row) of Maps (one entry for each column
using the column name as the key). Each item in the Flux will be of the form returned by this interface's
queryForMap() methods.
queryForFlux in interface ReactiveCqlOperationscql - static CQL to execute, must not be empty or null.Flux that contains a Map per row.DataAccessException - if there is any problem executing the query.ReactiveCqlOperations.queryForFlux(String, Object[])public reactor.core.publisher.Mono<ReactiveResultSet> queryForResultSet(String cql) throws DataAccessException
ReactiveCqlOperations
Uses a CQL Statement, not a PreparedStatement. If you want to execute a static query with a
PreparedStatement, use the overloaded queryForResultSet method with null as argument
array.
The results will be mapped to an ReactiveResultSet.
queryForResultSet in interface ReactiveCqlOperationscql - static CQL to execute, must not be empty or null.ReactiveResultSet representation.DataAccessException - if there is any problem executing the query.ReactiveCqlOperations.queryForResultSet(String, Object[])public reactor.core.publisher.Flux<com.datastax.oss.driver.api.core.cql.Row> queryForRows(String cql) throws DataAccessException
ReactiveCqlOperations
Uses a CQL Statement, not a PreparedStatement. If you want to execute a static query with a
PreparedStatement, use the overloaded queryForResultSet method with null as argument
array.
The results will be mapped to Rows.
queryForRows in interface ReactiveCqlOperationscql - static CQL to execute, must not be empty or null.DataAccessException - if there is any problem executing the query.ReactiveCqlOperations.queryForResultSet(String, Object[])public reactor.core.publisher.Flux<Boolean> execute(org.reactivestreams.Publisher<String> statementPublisher) throws DataAccessException
ReactiveCqlOperationsPublisher.execute in interface ReactiveCqlOperationsstatementPublisher - defining a Publisher of CQL statements that will be executed.DataAccessException - if there is any problem executing the batch.public reactor.core.publisher.Mono<Boolean> execute(com.datastax.oss.driver.api.core.cql.Statement<?> statement) throws DataAccessException
ReactiveCqlOperationsexecute in interface ReactiveCqlOperationsstatement - static CQL Statement, must not be null.DataAccessException - if there is any problem executing the query.public <T> reactor.core.publisher.Flux<T> query(com.datastax.oss.driver.api.core.cql.Statement<?> statement,
ReactiveResultSetExtractor<T> rse)
throws DataAccessException
ReactiveCqlOperationsReactiveResultSet with a ReactiveResultSetExtractor.
Uses a CQL Statement, not a PreparedStatement. If you want to execute a static query with a
PreparedStatement, use the overloaded query method with null as argument array.
query in interface ReactiveCqlOperationsstatement - static CQL Statement, must not be null.rse - object that will extract all rows of results, must not be null.DataAccessException - if there is any problem executing the query.ReactiveCqlOperations.query(String, ReactiveResultSetExtractor, Object...)public <T> reactor.core.publisher.Flux<T> query(com.datastax.oss.driver.api.core.cql.Statement<?> statement,
RowMapper<T> rowMapper)
throws DataAccessException
ReactiveCqlOperationsRowMapper.
Uses a CQL Statement, not a PreparedStatement. If you want to execute a static query with a
PreparedStatement, use the overloaded query method with null as argument array.
query in interface ReactiveCqlOperationsstatement - static CQL Statement, must not be null.rowMapper - object that will map one object per row, must not be null.Flux, containing mapped objects.DataAccessException - if there is any problem executing the query.ReactiveCqlOperations.query(String, RowMapper, Object[])public <T> reactor.core.publisher.Mono<T> queryForObject(com.datastax.oss.driver.api.core.cql.Statement<?> statement,
RowMapper<T> rowMapper)
throws DataAccessException
ReactiveCqlOperationsRowMapper.
Uses a CQL Statement, not a PreparedStatement. If you want to execute a static query with a
PreparedStatement, use the overloaded ReactiveCqlOperations.queryForObject(String, RowMapper, Object...) method with
null as argument array.
queryForObject in interface ReactiveCqlOperationsstatement - static CQL Statement, must not be null.rowMapper - object that will map one object per row, must not be null.IncorrectResultSizeDataAccessException - if the query does not return exactly one row.DataAccessException - if there is any problem executing the query.ReactiveCqlOperations.queryForObject(String, RowMapper, Object[])public <T> reactor.core.publisher.Mono<T> queryForObject(com.datastax.oss.driver.api.core.cql.Statement<?> statement,
Class<T> requiredType)
throws DataAccessException
ReactiveCqlOperations
Uses a CQL Statement, not a PreparedStatement. If you want to execute a static query with a
PreparedStatement, use the overloaded ReactiveCqlOperations.queryForObject(String, Class, Object...) method with
null as argument array.
This method is useful for running static CQL with a known outcome. The query is expected to be a single row/single column query; the returned result will be directly mapped to the corresponding object type.
queryForObject in interface ReactiveCqlOperationsstatement - static CQL Statement, must not be null.requiredType - the type that the result object is expected to match, must not be null.Mono.empty() in case of CQL NULL.IncorrectResultSizeDataAccessException - if the query does not return exactly one row, or does not return
exactly one column in that row.DataAccessException - if there is any problem executing the query.ReactiveCqlOperations.queryForObject(String, Class, Object[])public reactor.core.publisher.Mono<Map<String,Object>> queryForMap(com.datastax.oss.driver.api.core.cql.Statement<?> statement) throws DataAccessException
ReactiveCqlOperations
Uses a CQL Statement, not a PreparedStatement. If you want to execute a static query with a
PreparedStatement, use the overloaded ReactiveCqlOperations.queryForMap(String, Object...) method with null
as argument array.
The query is expected to be a single row query; the result row will be mapped to a Map (one entry for each column, using the column name as the key).
queryForMap in interface ReactiveCqlOperationsstatement - static CQL Statement, must not be null.IncorrectResultSizeDataAccessException - if the query does not return exactly one row.DataAccessException - if there is any problem executing the query.ReactiveCqlOperations.queryForMap(String, Object[]),
ColumnMapRowMapperpublic <T> reactor.core.publisher.Flux<T> queryForFlux(com.datastax.oss.driver.api.core.cql.Statement<?> statement,
Class<T> elementType)
throws DataAccessException
ReactiveCqlOperationsFlux, given static CQL.
Uses a CQL Statement, not a PreparedStatement. If you want to execute a static query with a
PreparedStatement, use the overloaded queryForFlux method with null as argument array.
The results will be mapped to a Flux (one item for each row) of result objects, each of them matching the
specified element type.
queryForFlux in interface ReactiveCqlOperationsstatement - static CQL Statement, must not be null.elementType - the required type of element in the result Flux (for example, Integer.class),
must not be null.Flux of objects that match the specified element type.DataAccessException - if there is any problem executing the query.ReactiveCqlOperations.queryForFlux(String, Class, Object[]),
SingleColumnRowMapperpublic reactor.core.publisher.Flux<Map<String,Object>> queryForFlux(com.datastax.oss.driver.api.core.cql.Statement<?> statement) throws DataAccessException
ReactiveCqlOperationsFlux, given static CQL.
Uses a CQL Statement, not a PreparedStatement. If you want to execute a static query with a
PreparedStatement, use the overloaded queryForFlux method with null as argument array.
The results will be mapped to a Flux (one item for each row) of Maps (one entry for each column
using the column name as the key). Each item in the Flux will be of the form returned by this interface's
queryForMap() methods.
queryForFlux in interface ReactiveCqlOperationsstatement - static CQL Statement, must not be null.Flux that contains a Map per row.DataAccessException - if there is any problem executing the query.ReactiveCqlOperations.queryForFlux(String, Object[])public reactor.core.publisher.Mono<ReactiveResultSet> queryForResultSet(com.datastax.oss.driver.api.core.cql.Statement<?> statement) throws DataAccessException
ReactiveCqlOperations
Uses a CQL Statement, not a PreparedStatement. If you want to execute a static query with a
PreparedStatement, use the overloaded queryForResultSet method with null as argument
array.
The results will be mapped to an ReactiveResultSet.
queryForResultSet in interface ReactiveCqlOperationsstatement - static CQL Statement, must not be null.ReactiveResultSet representation.DataAccessException - if there is any problem executing the query.ReactiveCqlOperations.queryForResultSet(String, Object[])public reactor.core.publisher.Flux<com.datastax.oss.driver.api.core.cql.Row> queryForRows(com.datastax.oss.driver.api.core.cql.Statement<?> statement)
throws DataAccessException
ReactiveCqlOperations
Uses a CQL Statement, not a PreparedStatement. If you want to execute a static query with a
PreparedStatement, use the overloaded queryForResultSet method with null as argument
array.
The results will be mapped to Rows.
queryForRows in interface ReactiveCqlOperationsstatement - static CQL Statement, must not be null.DataAccessException - if there is any problem executing the query.ReactiveCqlOperations.queryForResultSet(String, Object[])public <T> reactor.core.publisher.Flux<T> execute(ReactivePreparedStatementCreator psc, ReactivePreparedStatementCallback<T> action) throws DataAccessException
ReactiveCqlOperationsPreparedStatement.
This allows for implementing arbitrary data access operations on a single PreparedStatement, within
Spring's managed CQL environment: that is, participating in Spring-managed transactions and converting CQL
DriverExceptions into Spring's DataAccessException hierarchy.
The callback action can return a result object, for example a domain object or a collection of domain objects.
execute in interface ReactiveCqlOperationspsc - object that can create a PreparedStatement given a
ReactiveSession, must not be null.action - callback object that specifies the action, must not be null.DataAccessException - if there is any problem executing the query.public <T> reactor.core.publisher.Flux<T> execute(String cql, ReactivePreparedStatementCallback<T> action) throws DataAccessException
ReactiveCqlOperationsPreparedStatement.
This allows for implementing arbitrary data access operations on a single Statement, within Spring's managed CQL
environment: that is, participating in Spring-managed transactions and converting CQL
DriverExceptions into Spring's DataAccessException hierarchy.
The callback action can return a result object, for example a domain object or a collection of domain objects.
execute in interface ReactiveCqlOperationscql - static CQL to execute, must not be empty or null.action - callback object that specifies the action, must not be null.DataAccessException - if there is any problem executing the query.public <T> reactor.core.publisher.Flux<T> query(ReactivePreparedStatementCreator psc, @Nullable PreparedStatementBinder preparedStatementBinder, ReactiveResultSetExtractor<T> rse) throws DataAccessException
ReactiveResultSet with a ReactiveResultSetExtractor.query in interface ReactiveCqlOperationspsc - object that can create a PreparedStatement given a ReactiveSessionpreparedStatementBinder - object that knows how to set values on the prepared statement. If this is
null, the CQL will be assumed to contain no bind parameters.rse - object that will extract resultsReactiveResultSetExtractorDataAccessException - if there is any problempublic <T> reactor.core.publisher.Flux<T> query(ReactivePreparedStatementCreator psc, ReactiveResultSetExtractor<T> rse) throws DataAccessException
ReactiveCqlOperationsReactiveResultSet with a ReactiveResultSetExtractor.query in interface ReactiveCqlOperationspsc - object that can create a PreparedStatement given a
ReactiveSession, must not be null.rse - object that will extract results, must not be null.ReactiveResultSetExtractorDataAccessException - if there is any problem executing the query.public <T> reactor.core.publisher.Flux<T> query(String cql, @Nullable PreparedStatementBinder psb, ReactiveResultSetExtractor<T> rse) throws DataAccessException
ReactiveCqlOperationsReactiveResultSet with a ReactiveResultSetExtractor.query in interface ReactiveCqlOperationscql - static CQL to execute, must not be empty or null.psb - object that knows how to set values on the prepared statement. If this is null, the CQL will
be assumed to contain no bind parameters. Even if there are no bind parameters, this object may be used to
set fetch size and other performance options.rse - object that will extract results, must not be null.ReactiveResultSetExtractor.DataAccessException - if there is any problem executing the query.public <T> reactor.core.publisher.Flux<T> query(String cql, ReactiveResultSetExtractor<T> rse, Object... args) throws DataAccessException
ReactiveCqlOperationsReactiveResultSet with a ReactiveResultSetExtractor.query in interface ReactiveCqlOperationscql - static CQL to execute, must not be empty or null.rse - object that will extract results, must not be null.args - arguments to bind to the query (leaving it to the PreparedStatement to guess the corresponding
CQL type).ReactiveResultSetExtractorDataAccessException - if there is any problem executing the query.public <T> reactor.core.publisher.Flux<T> query(ReactivePreparedStatementCreator psc, RowMapper<T> rowMapper) throws DataAccessException
ReactiveCqlOperationsRowMapper.query in interface ReactiveCqlOperationspsc - object that can create a PreparedStatement given a
ReactiveSession, must not be null.rowMapper - object that will map one object per row, must not be null.Flux, containing mapped objects.DataAccessException - if there is any problem executing the query.public <T> reactor.core.publisher.Flux<T> query(String cql, @Nullable PreparedStatementBinder psb, RowMapper<T> rowMapper) throws DataAccessException
ReactiveCqlOperationsPreparedStatementBinder implementation that
knows how to bind values to the query, mapping each row to a Java object via a RowMapper.query in interface ReactiveCqlOperationscql - static CQL to execute, must not be empty or null.psb - object that knows how to set values on the prepared statement. If this is null, the CQL will
be assumed to contain no bind parameters. Even if there are no bind parameters, this object may be used to
set fetch size and other performance options.rowMapper - object that will map one object per row, must not be null.Flux, containing mapped objects.DataAccessException - if there is any problem executing the query.public <T> reactor.core.publisher.Flux<T> query(ReactivePreparedStatementCreator psc, @Nullable PreparedStatementBinder psb, RowMapper<T> rowMapper) throws DataAccessException
ReactiveCqlOperationsPreparedStatementBinder implementation that knows how to bind values
to the query, mapping each row to a Java object via a RowMapper.query in interface ReactiveCqlOperationspsc - object that can create a PreparedStatement given a
CqlSession, must not be null.psb - object that knows how to set values on the prepared statement. If this is null, the CQL will
be assumed to contain no bind parameters. Even if there are no bind parameters, this object may be used to
set fetch size and other performance options.rowMapper - object that will map one object per row, must not be null.Flux, containing mapped objects.DataAccessException - if there is any problem executing the query.public <T> reactor.core.publisher.Flux<T> query(String cql, RowMapper<T> rowMapper, Object... args) throws DataAccessException
ReactiveCqlOperationsRowMapper.query in interface ReactiveCqlOperationscql - static CQL to execute, must not be empty or null.rowMapper - object that will map one object per rowargs - arguments to bind to the query (leaving it to the PreparedStatement to guess the corresponding
CQL type)Flux, containing mapped objectsDataAccessException - if there is any problem executing the query.public <T> reactor.core.publisher.Mono<T> queryForObject(String cql, RowMapper<T> rowMapper, Object... args) throws DataAccessException
ReactiveCqlOperationsRowMapper.queryForObject in interface ReactiveCqlOperationscql - static CQL to execute, must not be empty or null.rowMapper - object that will map one object per row, must not be null.args - arguments to bind to the query (leaving it to the PreparedStatement to guess the corresponding
CQL type)IncorrectResultSizeDataAccessException - if the query does not return exactly one row.DataAccessException - if there is any problem executing the query.public <T> reactor.core.publisher.Mono<T> queryForObject(String cql, Class<T> requiredType, Object... args) throws DataAccessException
ReactiveCqlOperationsThe query is expected to be a single row/single column query; the returned result will be directly mapped to the corresponding object type.
queryForObject in interface ReactiveCqlOperationscql - static CQL to execute, must not be empty or null.requiredType - the type that the result object is expected to match, must not be null.args - arguments to bind to the query (leaving it to the PreparedStatement to guess the corresponding CQL
type)Mono.empty() in case of CQL NULL.IncorrectResultSizeDataAccessException - if the query does not return exactly one row, or does not return
exactly one column in that row.DataAccessException - if there is any problem executing the query.ReactiveCqlOperations.queryForObject(String, Class)public reactor.core.publisher.Mono<Map<String,Object>> queryForMap(String cql, Object... args) throws DataAccessException
ReactiveCqlOperationsThe query is expected to be a single row query; the result row will be mapped to a Map (one entry for each column, using the column name as the key).
queryForMap in interface ReactiveCqlOperationscql - static CQL to execute, must not be empty or null.args - arguments to bind to the query (leaving it to the PreparedStatement to guess the corresponding
CQL type).IncorrectResultSizeDataAccessException - if the query does not return exactly one rowDataAccessException - if there is any problem executing the query.ReactiveCqlOperations.queryForMap(String),
ColumnMapRowMapperpublic <T> reactor.core.publisher.Flux<T> queryForFlux(String cql, Class<T> elementType, Object... args) throws DataAccessException
ReactiveCqlOperationsFlux.
The results will be mapped to a Flux (one item for each row) of result objects, each of them matching the
specified element type.
queryForFlux in interface ReactiveCqlOperationscql - static CQL to execute, must not be empty or null.elementType - the required type of element in the result Flux (for example, Integer.class),
must not be null.args - arguments to bind to the query (leaving it to the PreparedStatement to guess the corresponding
CQL type).Flux of objects that match the specified element type.DataAccessException - if there is any problem executing the query.ReactiveCqlOperations.queryForFlux(String, Class),
SingleColumnRowMapperpublic reactor.core.publisher.Flux<Map<String,Object>> queryForFlux(String cql, Object... args) throws DataAccessException
ReactiveCqlOperationsFlux.
The results will be mapped to a Flux (one item for each row) of Maps (one entry for each column,
using the column name as the key). Each item in the Flux will be of the form returned by this interface's
queryForMap() methods.
queryForFlux in interface ReactiveCqlOperationscql - static CQL to execute, must not be empty or null.args - arguments to bind to the query (leaving it to the PreparedStatement to guess the corresponding
CQL type).Flux that contains a Map per rowDataAccessException - if there is any problem executing the query.ReactiveCqlOperations.queryForFlux(String)public reactor.core.publisher.Mono<ReactiveResultSet> queryForResultSet(String cql, Object... args) throws DataAccessException
ReactiveCqlOperations
The results will be mapped to an ReactiveResultSet.
queryForResultSet in interface ReactiveCqlOperationscql - static CQL to execute, must not be empty or null.args - arguments to bind to the query (leaving it to the PreparedStatement to guess the corresponding
CQL type).ReactiveResultSet representation.DataAccessException - if there is any problem executing the query.ReactiveCqlOperations.queryForResultSet(String)public reactor.core.publisher.Flux<com.datastax.oss.driver.api.core.cql.Row> queryForRows(String cql, Object... args) throws DataAccessException
ReactiveCqlOperations
The results will be mapped to Rows.
queryForRows in interface ReactiveCqlOperationscql - static CQL to execute, must not be empty or null.args - arguments to bind to the query (leaving it to the PreparedStatement to guess the corresponding
CQL type).Row representation.DataAccessException - if there is any problem executing the query.ReactiveCqlOperations.queryForResultSet(String)public reactor.core.publisher.Mono<Boolean> execute(ReactivePreparedStatementCreator psc) throws DataAccessException
ReactiveCqlOperationsReactivePreparedStatementCreator to provide CQL and any required parameters.execute in interface ReactiveCqlOperationspsc - object that provides CQL and any necessary parameters, must not be null.DataAccessException - if there is any problem issuing the execution.public reactor.core.publisher.Mono<Boolean> execute(String cql, @Nullable PreparedStatementBinder psb) throws DataAccessException
ReactiveCqlOperationsPreparedStatementBinder to set bind parameters, with given CQL. Simpler than
using a ReactivePreparedStatementCreator as this method will create the PreparedStatement: The
PreparedStatementBinder just needs to set parameters.execute in interface ReactiveCqlOperationscql - static CQL to execute, must not be empty or null.psb - object that knows how to set values on the prepared statement. If this is null, the CQL will
be assumed to contain no bind parameters. Even if there are no bind parameters, this object may be used to
set fetch size and other performance options.DataAccessException - if there is any problem executing the query.public reactor.core.publisher.Mono<Boolean> execute(String cql, Object... args) throws DataAccessException
ReactiveCqlOperationsexecute in interface ReactiveCqlOperationscql - static CQL to execute, must not be empty or null.args - arguments to bind to the query (leaving it to the PreparedStatement to guess the corresponding
CQL type).DataAccessException - if there is any problem executing the query.public reactor.core.publisher.Flux<Boolean> execute(String cql, org.reactivestreams.Publisher<Object[]> args) throws DataAccessException
ReactiveCqlOperationsexecute in interface ReactiveCqlOperationscql - static CQL to execute containing bind parameters, must not be empty or null.args - arguments to bind to the query (leaving it to the PreparedStatement to guess the corresponding
CQL type).DataAccessException - if there is any problem executing the query.protected ReactivePreparedStatementCreator newReactivePreparedStatementCreator(String cql)
ReactivePreparedStatementCreator using the CQL passed in. By default, we'll create
an SimpleReactivePreparedStatementCreator. This method allows for the creation to be overridden by
subclasses.cql - static CQL to execute, must not be empty or null.ReactivePreparedStatementCreator to useprotected <T> reactor.core.publisher.Flux<T> createFlux(com.datastax.oss.driver.api.core.cql.Statement<?> statement,
ReactiveStatementCallback<T> callback)
Flux given a ReactiveStatementCallback without exception translation.callback - must not be null.Flux wrapping the ReactiveStatementCallback.protected <T> reactor.core.publisher.Mono<T> createMono(com.datastax.oss.driver.api.core.cql.Statement<?> statement,
ReactiveStatementCallback<T> callback)
Mono given a ReactiveStatementCallback without exception translation.callback - must not be null.Mono wrapping the ReactiveStatementCallback.protected <T> reactor.core.publisher.Flux<T> createFlux(ReactiveSessionCallback<T> callback)
Flux given a ReactiveSessionCallback without exception translation.callback - must not be null.Flux wrapping the ReactiveSessionCallback.protected Function<Throwable,Throwable> translateException(String task, @Nullable String cql)
Function intended for Mono#otherwise(Function) usage.task - readable text describing the task being attemptedcql - CQL query or update that caused the problem (may be null)FunctionCqlProviderprotected RowMapper<Map<String,Object>> getColumnMapRowMapper()
ColumnMapRowMapperprotected <T> RowMapper<T> getSingleColumnRowMapper(Class<T> requiredType)
requiredType - the type that each result object is expected to matchSingleColumnRowMapperprotected com.datastax.oss.driver.api.core.cql.Statement<?> applyStatementSettings(com.datastax.oss.driver.api.core.cql.Statement<?> statement)
stmt - the CQL Statement to preparesetConsistencyLevel(ConsistencyLevel),
setSerialConsistencyLevel(ConsistencyLevel),
setPageSize(int),
setExecutionProfile(String),
setExecutionProfileResolver(ExecutionProfileResolver)protected PreparedStatementBinder newArgPreparedStatementBinder(Object[] args)
By default, we'll create an ArgumentPreparedStatementBinder. This method allows for the creation to be
overridden by subclasses.
args - object array with argumentsPreparedStatementBinder to useCopyright © 2011–2021 Pivotal Software, Inc.. All rights reserved.