Class ReactiveCqlTemplate

java.lang.Object
org.springframework.data.cassandra.core.cql.ReactiveCassandraAccessor
org.springframework.data.cassandra.core.cql.ReactiveCqlTemplate
All Implemented Interfaces:
InitializingBean, ReactiveCqlOperations

public class ReactiveCqlTemplate extends ReactiveCassandraAccessor implements ReactiveCqlOperations
This is the central class in the CQL core package for reactive Cassandra data access. It simplifies the use of CQL and helps to avoid common errors. It executes core CQL workflow, leaving application code to provide CQL and extract results. This class executes CQL queries or updates, initiating iteration over 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.

Since:
2.0
Author:
Mark Paluch, Tomasz Lelek
See Also: