Class AsyncCqlTemplate

java.lang.Object
org.springframework.data.cassandra.core.cql.CassandraAccessor
org.springframework.data.cassandra.core.cql.AsyncCqlTemplate
All Implemented Interfaces:
InitializingBean, AsyncCqlOperations

public class AsyncCqlTemplate extends CassandraAccessor implements AsyncCqlOperations
This is the central class in the CQL core package for asynchronous 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 ResultSets 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 AsyncResultSetExtractor interface extracts values from a ResultSet. See also PreparedStatementBinder and RowMapper for two popular alternative callback interfaces.

Can be used within a service implementation via direct instantiation with a CqlSession reference, or get prepared in an application context and given to services as bean reference. Note: The CqlSession 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.cqlTemplate" as log category.

NOTE: An instance of this class is thread-safe once configured.

Since:
2.0
Author:
Mark Paluch, John Blum
See Also: