public interface CassandraOperations extends FluentCassandraOperations
CassandraTemplate
. Not often used
directly, but a useful option to enhance testability, as it can easily be mocked or stubbed.CassandraTemplate
,
CqlOperations
,
Statement
,
InsertOptions
,
UpdateOptions
ExecutableSelectOperation.ExecutableSelect<T>, ExecutableSelectOperation.SelectWithProjection<T>, ExecutableSelectOperation.SelectWithQuery<T>, ExecutableSelectOperation.SelectWithTable<T>, ExecutableSelectOperation.TerminatingSelect<T>
ExecutableInsertOperation.ExecutableInsert<T>, ExecutableInsertOperation.InsertWithOptions<T>, ExecutableInsertOperation.InsertWithTable<T>, ExecutableInsertOperation.TerminatingInsert<T>
ExecutableUpdateOperation.ExecutableUpdate, ExecutableUpdateOperation.TerminatingUpdate, ExecutableUpdateOperation.UpdateWithQuery, ExecutableUpdateOperation.UpdateWithTable
ExecutableDeleteOperation.DeleteWithQuery, ExecutableDeleteOperation.DeleteWithTable, ExecutableDeleteOperation.ExecutableDelete, ExecutableDeleteOperation.TerminatingDelete
Modifier and Type | Method and Description |
---|---|
CassandraBatchOperations |
batchOps()
Returns a new
CassandraBatchOperations . |
long |
count(Class<?> entityClass)
Returns the number of rows for the given entity class.
|
long |
count(Query query,
Class<?> entityClass)
Returns the number of rows for the given entity class applying
Query . |
void |
delete(Object entity)
Delete the given entity and return the entity if the delete was applied.
|
default WriteResult |
delete(Object entity,
DeleteOptions options)
Delete the given entity applying
DeleteOptions and return the entity if the delete was applied. |
WriteResult |
delete(Object entity,
QueryOptions options)
Delete the given entity applying
QueryOptions and return the entity if the delete was applied. |
boolean |
delete(Query query,
Class<?> entityClass)
Remove entities (rows)/columns from the table by
Query . |
boolean |
deleteById(Object id,
Class<?> entityClass)
Remove the given object from the table by id.
|
com.datastax.oss.driver.api.core.cql.ResultSet |
execute(com.datastax.oss.driver.api.core.cql.Statement<?> statement)
Execute the a Cassandra
Statement . |
boolean |
exists(Object id,
Class<?> entityClass)
Determine whether a row of
entityClass with the given id exists. |
boolean |
exists(Query query,
Class<?> entityClass)
Determine whether the result for
entityClass Query yields at least one row. |
CassandraConverter |
getConverter()
Returns the underlying
CassandraConverter . |
CqlOperations |
getCqlOperations()
Expose the underlying
CqlOperations to allow CQL operations. |
com.datastax.oss.driver.api.core.CqlIdentifier |
getTableName(Class<?> entityClass)
The table name used for the specified class by this template.
|
<T> T |
insert(T entity)
Insert the given entity and return the entity if the insert was applied.
|
<T> EntityWriteResult<T> |
insert(T entity,
InsertOptions options)
Insert the given entity applying
WriteOptions and return the entity if the insert was applied. |
<T> List<T> |
select(Query query,
Class<T> entityClass)
Execute a
SELECT query and convert the resulting items to a List of entities. |
<T> List<T> |
select(com.datastax.oss.driver.api.core.cql.Statement<?> statement,
Class<T> entityClass)
Execute a
SELECT query and convert the resulting items to a List of entities. |
<T> List<T> |
select(String cql,
Class<T> entityClass)
Execute a
SELECT query and convert the resulting items to a List of entities. |
<T> T |
selectOne(Query query,
Class<T> entityClass)
Execute a
SELECT query and convert the resulting item to an entity. |
<T> T |
selectOne(com.datastax.oss.driver.api.core.cql.Statement<?> statement,
Class<T> entityClass)
Execute a
SELECT query and convert the resulting item to an entity. |
<T> T |
selectOne(String cql,
Class<T> entityClass)
Execute a
SELECT query and convert the resulting item to an entity. |
<T> T |
selectOneById(Object id,
Class<T> entityClass)
Execute the Select by
id for the given entityClass . |
<T> Slice<T> |
slice(Query query,
Class<T> entityClass)
Execute a
SELECT query with paging and convert the result set to a Slice of entities. |
<T> Slice<T> |
slice(com.datastax.oss.driver.api.core.cql.Statement<?> statement,
Class<T> entityClass)
Execute a
SELECT query with paging and convert the result set to a Slice of entities. |
<T> Stream<T> |
stream(Query query,
Class<T> entityClass)
Execute a
SELECT query and convert the resulting items to a Iterator of entities. |
<T> Stream<T> |
stream(com.datastax.oss.driver.api.core.cql.Statement<?> statement,
Class<T> entityClass)
Execute a
SELECT query and convert the resulting items to a Iterator of entities. |
<T> Stream<T> |
stream(String cql,
Class<T> entityClass)
Execute a
SELECT query and convert the resulting items to a Iterator of entities. |
void |
truncate(Class<?> entityClass)
Execute a
TRUNCATE query to remove all entities of a given class. |
boolean |
update(Query query,
Update update,
Class<?> entityClass)
Update the queried entities and return true if the update was applied.
|
<T> T |
update(T entity)
Update the given entity and return the entity if the update was applied.
|
<T> EntityWriteResult<T> |
update(T entity,
UpdateOptions options)
Update the given entity applying
WriteOptions and return the entity if the update was applied. |
query
insert
update
delete
CassandraBatchOperations batchOps()
CassandraBatchOperations
. Each CassandraBatchOperations
instance can be executed only
once so you might want to obtain new CassandraBatchOperations
instances for each batch.CassandraBatchOperations
associated with the given entity class.CqlOperations getCqlOperations()
CqlOperations
to allow CQL operations.CqlOperations
.CqlOperations
CassandraConverter getConverter()
CassandraConverter
.CassandraConverter
.com.datastax.oss.driver.api.core.CqlIdentifier getTableName(Class<?> entityClass)
entityClass
- The entity type must not be null.CqlIdentifier
<T> List<T> select(String cql, Class<T> entityClass) throws DataAccessException
SELECT
query and convert the resulting items to a List
of entities.cql
- must not be null.entityClass
- The entity type must not be null.DataAccessException
- if there is any problem executing the query.<T> Stream<T> stream(String cql, Class<T> entityClass) throws DataAccessException
SELECT
query and convert the resulting items to a Iterator
of entities.
Returns a Iterator
that wraps the Cassandra com.datastax.driver.core.ResultSet
.
T
- element return type.cql
- query to execute. Must not be empty or null.entityClass
- Class type of the elements in the Iterator
stream. Must not be null.Iterator
(stream) over the elements in the query result set.DataAccessException
- if there is any problem executing the query.@Nullable <T> T selectOne(String cql, Class<T> entityClass) throws DataAccessException
SELECT
query and convert the resulting item to an entity.cql
- must not be null.entityClass
- The entity type must not be null.DataAccessException
- if there is any problem executing the query.com.datastax.oss.driver.api.core.cql.ResultSet execute(com.datastax.oss.driver.api.core.cql.Statement<?> statement) throws DataAccessException
Statement
. Any errors that result from executing this command will be converted
into Spring's DAO exception hierarchy.statement
- a Cassandra Statement
, must not be null.ResultSet
.DataAccessException
- if there is any problem executing the query.<T> List<T> select(com.datastax.oss.driver.api.core.cql.Statement<?> statement, Class<T> entityClass) throws DataAccessException
SELECT
query and convert the resulting items to a List
of entities.statement
- must not be null.entityClass
- The entity type must not be null.DataAccessException
- if there is any problem executing the query.<T> Slice<T> slice(com.datastax.oss.driver.api.core.cql.Statement<?> statement, Class<T> entityClass) throws DataAccessException
SELECT
query with paging and convert the result set to a Slice
of entities. A sliced
query translates the effective fetch size
to the page size.statement
- the CQL statement, must not be null.entityClass
- The entity type must not be null.DataAccessException
- if there is any problem executing the query.<T> Stream<T> stream(com.datastax.oss.driver.api.core.cql.Statement<?> statement, Class<T> entityClass) throws DataAccessException
SELECT
query and convert the resulting items to a Iterator
of entities.
Returns a Iterator
that wraps the Cassandra com.datastax.driver.core.ResultSet
.
T
- element return type.statement
- query to execute. Must not be empty or null.entityClass
- Class type of the elements in the Iterator
stream. Must not be null.Iterator
(stream) over the elements in the query result set.DataAccessException
- if there is any problem executing the query.@Nullable <T> T selectOne(com.datastax.oss.driver.api.core.cql.Statement<?> statement, Class<T> entityClass) throws DataAccessException
SELECT
query and convert the resulting item to an entity.statement
- must not be null.entityClass
- The entity type must not be null.DataAccessException
- if there is any problem executing the query.<T> List<T> select(Query query, Class<T> entityClass) throws DataAccessException
SELECT
query and convert the resulting items to a List
of entities.query
- must not be null.entityClass
- The entity type must not be null.DataAccessException
- if there is any problem executing the query.<T> Slice<T> slice(Query query, Class<T> entityClass) throws DataAccessException
SELECT
query with paging and convert the result set to a Slice
of entities.query
- the query object used to create a CQL statement, must not be null.entityClass
- The entity type must not be null.DataAccessException
- if there is any problem executing the query.CassandraPageRequest
<T> Stream<T> stream(Query query, Class<T> entityClass) throws DataAccessException
SELECT
query and convert the resulting items to a Iterator
of entities.
Returns a Iterator
that wraps the Cassandra com.datastax.driver.core.ResultSet
.
T
- element return type.query
- query to execute. Must not be empty or null.entityClass
- Class type of the elements in the Iterator
stream. Must not be null.Iterator
(stream) over the elements in the query result set.DataAccessException
- if there is any problem executing the query.@Nullable <T> T selectOne(Query query, Class<T> entityClass) throws DataAccessException
SELECT
query and convert the resulting item to an entity.query
- must not be null.entityClass
- The entity type must not be null.DataAccessException
- if there is any problem executing the query.boolean update(Query query, Update update, Class<?> entityClass) throws DataAccessException
query
- must not be null.update
- must not be null.entityClass
- The entity type must not be null.DataAccessException
- if there is any problem executing the query.boolean delete(Query query, Class<?> entityClass) throws DataAccessException
Query
.query
- must not be null.entityClass
- The entity type must not be null.DataAccessException
- if there is any problem executing the query.long count(Class<?> entityClass) throws DataAccessException
entityClass
- type
of the entity; must not be null.DataAccessException
- if any problem occurs while executing the query.long count(Query query, Class<?> entityClass) throws DataAccessException
Query
. This overridden method allows users
to further refine the selection criteria using a Query
predicate to determine how many entities of the
given type
match the criteria.query
- user-defined count Query
to execute; must not be null.entityClass
- type
of the entity; must not be null.DataAccessException
- if any problem occurs while executing the query.boolean exists(Object id, Class<?> entityClass) throws DataAccessException
entityClass
with the given id
exists.id
- Id value. For single primary keys it's the plain value. For composite primary keys either, it's an
instance of either PrimaryKeyClass
or
MapId
. Must not be null.entityClass
- type
of the entity; must not be null.DataAccessException
- if any problem occurs while executing the query.boolean exists(Query query, Class<?> entityClass) throws DataAccessException
entityClass
Query
yields at least one row.query
- user-defined exists Query
to execute; must not be null.entityClass
- type
of the entity; must not be null.DataAccessException
- if any problem occurs while executing the query.@Nullable <T> T selectOneById(Object id, Class<T> entityClass) throws DataAccessException
id
for the given entityClass
.id
- the Id value. For single primary keys it's the plain value. For composite primary keys either the
PrimaryKeyClass
or
MapId
. Must not be null.entityClass
- The entity type must not be null.DataAccessException
- if there is any problem executing the query.<T> T insert(T entity) throws DataAccessException
entity
- The entity to insert, must not be null.DataAccessException
- if there is any problem executing the query.<T> EntityWriteResult<T> insert(T entity, InsertOptions options) throws DataAccessException
WriteOptions
and return the entity if the insert was applied.entity
- The entity to insert, must not be null.options
- must not be null.EntityWriteResult
for this operation.DataAccessException
- if there is any problem executing the query.InsertOptions.empty()
<T> T update(T entity) throws DataAccessException
entity
- The entity to update, must not be null.DataAccessException
- if there is any problem executing the query.<T> EntityWriteResult<T> update(T entity, UpdateOptions options) throws DataAccessException
WriteOptions
and return the entity if the update was applied.entity
- The entity to update, must not be null.options
- must not be null.EntityWriteResult
for this operation.DataAccessException
- if there is any problem executing the query.UpdateOptions.empty()
void delete(Object entity) throws DataAccessException
entity
- must not be null.DataAccessException
- if there is any problem executing the query.WriteResult delete(Object entity, QueryOptions options) throws DataAccessException
QueryOptions
and return the entity if the delete was applied.entity
- must not be null.options
- must not be null.WriteResult
for this operation.DataAccessException
- if there is any problem executing the query.QueryOptions.empty()
default WriteResult delete(Object entity, DeleteOptions options) throws DataAccessException
DeleteOptions
and return the entity if the delete was applied.entity
- must not be null.options
- must not be null.WriteResult
for this operation.DataAccessException
- if there is any problem executing the query.DeleteOptions.empty()
boolean deleteById(Object id, Class<?> entityClass) throws DataAccessException
id
- the Id value. For single primary keys it's the plain value. For composite primary keys either the
PrimaryKeyClass
or
MapId
. Must not be null.entityClass
- The entity type must not be null.DataAccessException
- if there is any problem executing the query.void truncate(Class<?> entityClass) throws DataAccessException
TRUNCATE
query to remove all entities of a given class.entityClass
- The entity type must not be null.DataAccessException
- if there is any problem executing the query.Copyright © 2011–2021 Pivotal Software, Inc.. All rights reserved.