Interface SessionCallback<T>
- Functional Interface:
- This is a functional interface and can therefore be used as the assignment target for a lambda expression or method reference.
Generic callback interface for code that operates on a Cassandra
CqlSession
. Allows to execute any number of
operations on a single session, using any type and number of statements.
This is particularly useful for delegating to existing data access code that expects a CqlSession
to work on
and throws DriverException
. For newly written code, it is strongly recommended to use CqlTemplate
's
more specific operations, for example a query
or update
variant.
- Author:
- David Webb, Mark Paluch
- See Also:
-
Method Summary
Modifier and TypeMethodDescriptiondoInSession
(com.datastax.oss.driver.api.core.CqlSession session) Gets called byCqlTemplate.execute(org.springframework.data.cassandra.core.cql.SessionCallback<T>)
with an active CassandraCqlSession
.
-
Method Details
-
doInSession
T doInSession(com.datastax.oss.driver.api.core.CqlSession session) throws com.datastax.oss.driver.api.core.DriverException, DataAccessException Gets called byCqlTemplate.execute(org.springframework.data.cassandra.core.cql.SessionCallback<T>)
with an active CassandraCqlSession
. Does not need to care about activating or closing theCqlSession
.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(java.lang.String, java.lang.Class<T>)
etc. A thrownRuntimeException
is treated as application exception: it gets propagated to the caller of the template.- Parameters:
session
- active Cassandra Session, must not be null.- Returns:
- a result object, or null if none.
- Throws:
com.datastax.oss.driver.api.core.DriverException
- if thrown by a Session method, to be auto-converted to aDataAccessException
.DataAccessException
- in case of custom exceptions.- See Also:
-