@FunctionalInterface public interface PreparedStatementCallback<T>
PreparedStatement
. Allows to execute any number of
operations on a single PreparedStatement
, for example a single Session#execute(Statement).
Used internally by {@link CqlTemplate}, but also useful for application code. Note that the passed-in {@link PreparedStatement} can have been created by the framework or by a custom {@link PreparedStatementCreator}. However, the latter is hardly ever necessary, as most custom callback actions will perform updates in which case a standard {@link PreparedStatement is fine. Custom actions will always set parameter values themselves, so that {@link PreparedStatementCreator} capability is not needed either.
AsyncCqlTemplate.execute(String, PreparedStatementCallback)
,
AsyncCqlTemplate.execute(AsyncPreparedStatementCreator, PreparedStatementCallback)
,
CqlTemplate.execute(String, PreparedStatementCallback)}
,
CqlTemplate.execute(PreparedStatementCreator, PreparedStatementCallback)
Modifier and Type | Method and Description |
---|---|
T |
doInPreparedStatement(com.datastax.driver.core.Session session,
com.datastax.driver.core.PreparedStatement preparedStatement)
Gets called by
CqlTemplate.execute(String, PreparedStatementCallback) with an active CQL session and
PreparedStatement . |
@Nullable T doInPreparedStatement(com.datastax.driver.core.Session session, com.datastax.driver.core.PreparedStatement preparedStatement) throws com.datastax.driver.core.exceptions.DriverException, DataAccessException
CqlTemplate.execute(String, PreparedStatementCallback)
with an active CQL session and
PreparedStatement
. Does not need to care about closing the session: this will all be handled by Spring's
CqlTemplate
.
Allows for returning a result object created within the callback, i.e. a domain object or a collection of domain
objects. Note that there's special support for single step actions: see
CqlTemplate.queryForObject(String, Class, Object...)
etc. A thrown RuntimeException is treated as
application exception, it gets propagated to the caller of the template.
session
- active Cassandra session, must not be null.preparedStatement
- the PreparedStatement
, must not be null.com.datastax.driver.core.exceptions.DriverException
- if thrown by a session method, to be auto-converted to a DataAccessException
.DataAccessException
- in case of custom exceptions.AsyncCqlTemplate.queryForObject(String, Class, Object...)
,
AsyncCqlOperations.queryForList(String, Class, Object...)
,
CqlTemplate.queryForObject(String, Class, Object...)
,
CqlTemplate.queryForList(String, Object...)
Copyright © 2011–2019 Pivotal Software, Inc.. All rights reserved.