public interface CassandraOperations
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
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.
|
boolean |
delete(Query query,
Class<?> entityClass)
Remove entities (rows)/columns from the table by
Query . |
<T> T |
delete(T entity)
Delete the given entity and return the entity if the delete was applied.
|
<T> T |
delete(T entity,
QueryOptions options)
Delete the given entity applying
QueryOptions and return the entity if the delete was applied. |
boolean |
deleteById(Object id,
Class<?> entityClass)
Remove the given object from the table by id.
|
boolean |
exists(Object id,
Class<?> entityClass)
Determine whether the row
entityClass with the given id exists. |
CassandraConverter |
getConverter()
Returns the underlying
CassandraConverter . |
CqlOperations |
getCqlOperations()
Expose the underlying
CqlOperations to allow CQL operations. |
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> 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.driver.core.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> List<T> |
selectBySimpleIds(Iterable<?> ids,
Class<T> entityClass)
Select objects for the given
entityClass and ids . |
<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.driver.core.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> 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.driver.core.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> T |
update(T entity,
UpdateOptions options)
Update the given entity applying
WriteOptions and return the entity if the update was applied. |
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.CassandraConverter getConverter()
CassandraConverter
.CassandraConverter
.CqlOperations getCqlOperations()
CqlOperations
to allow CQL operations.CqlOperations
.CqlOperations
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 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.<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.<T> List<T> select(com.datastax.driver.core.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> Stream<T> stream(com.datastax.driver.core.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 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.<T> T selectOne(com.datastax.driver.core.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> 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 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.<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
- must not be null.DataAccessException
- if there is any problem executing the query.boolean exists(Object id, Class<?> entityClass) throws DataAccessException
entityClass
with the given id
exists.id
- must not be null.entityClass
- The entity type must not be null.DataAccessException
- if there is any problem executing the query.<T> T selectOneById(Object id, Class<T> entityClass) throws DataAccessException
id
for the given entityClass
.id
- must not be null.entityClass
- The entity type must not be null.DataAccessException
- if there is any problem executing the query.<T> List<T> selectBySimpleIds(Iterable<?> ids, Class<T> entityClass) throws DataAccessException
entityClass
and ids
.ids
- 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> 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
- may be null.INSERT
operation was not applied.DataAccessException
- if there is any problem executing the query.<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> 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
- may be null.UPDATE
operation was not applied.DataAccessException
- if there is any problem executing the query.<T> T delete(T entity) throws DataAccessException
entity
- must not be null.DataAccessException
- if there is any problem executing the query.<T> T delete(T entity, QueryOptions options) throws DataAccessException
QueryOptions
and return the entity if the delete was applied.entity
- must not be null.options
- may be null.DataAccessException
- if there is any problem executing the query.boolean deleteById(Object id, Class<?> entityClass) throws DataAccessException
id
- 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–2017 Pivotal Software, Inc.. All rights reserved.