Interface ReactiveCassandraOperations
- All Superinterfaces:
ReactiveDeleteOperation
,ReactiveFluentCassandraOperations
,ReactiveInsertOperation
,ReactiveSelectOperation
,ReactiveUpdateOperation
- All Known Implementing Classes:
ReactiveCassandraTemplate
Interface specifying a basic set of reactive Cassandra operations. Implemented by
ReactiveCassandraTemplate
.
Not often used directly, but a useful option to enhance testability, as it can easily be mocked or stubbed.- Since:
- 2.0
- Author:
- Mark Paluch, Hleb Albau, Oleh Dokuka, Sam Lightfoot
- See Also:
-
Nested Class Summary
Nested classes/interfaces inherited from interface org.springframework.data.cassandra.core.ReactiveDeleteOperation
ReactiveDeleteOperation.DeleteWithQuery, ReactiveDeleteOperation.DeleteWithTable, ReactiveDeleteOperation.ReactiveDelete, ReactiveDeleteOperation.TerminatingDelete
Nested classes/interfaces inherited from interface org.springframework.data.cassandra.core.ReactiveInsertOperation
ReactiveInsertOperation.InsertWithOptions<T>, ReactiveInsertOperation.InsertWithTable<T>, ReactiveInsertOperation.ReactiveInsert<T>, ReactiveInsertOperation.TerminatingInsert<T>
Nested classes/interfaces inherited from interface org.springframework.data.cassandra.core.ReactiveSelectOperation
ReactiveSelectOperation.ReactiveSelect<T>, ReactiveSelectOperation.SelectWithProjection<T>, ReactiveSelectOperation.SelectWithQuery<T>, ReactiveSelectOperation.SelectWithTable<T>, ReactiveSelectOperation.TerminatingSelect<T>
Nested classes/interfaces inherited from interface org.springframework.data.cassandra.core.ReactiveUpdateOperation
ReactiveUpdateOperation.ReactiveUpdate, ReactiveUpdateOperation.TerminatingUpdate, ReactiveUpdateOperation.UpdateWithQuery, ReactiveUpdateOperation.UpdateWithTable
-
Method Summary
Modifier and TypeMethodDescriptiondefault ReactiveCassandraBatchOperations
batchOps()
Returns a newReactiveCassandraBatchOperations
usingBatchType.LOGGED
.batchOps
(com.datastax.oss.driver.api.core.cql.BatchType batchType) Returns a newReactiveCassandraBatchOperations
.Returns the number of rows for the given entity class.Returns the number of rows for the given entity class applyingQuery
.delete
(Object entity, QueryOptions options) Delete the given entity applyingQueryOptions
and emit the entity if the delete statement was applied.default Mono<WriteResult>
delete
(Object entity, DeleteOptions options) Delete the given entity applyingQueryOptions
and emit the entity if the delete statement was applied.Remove entities (rows)/columns from the table byQuery
.<T> Mono<T>
delete
(T entity) Delete the given entity and emit the entity if the delete statement was applied.deleteById
(Object id, Class<?> entityClass) Remove the given object from the table by id.execute
(com.datastax.oss.driver.api.core.cql.Statement<?> statement) Execute the given CassandraStatement
.Determine whether a row ofentityClass
with the givenid
exists.Determine whether the result forentityClass
Query
yields at least one row.Returns the underlyingCassandraConverter
.Expose the underlyingReactiveCqlOperations
to allow CQL operations.<T> Mono<T>
insert
(T entity) Insert the given entity and emit the entity if the insert was applied.<T> Mono<EntityWriteResult<T>>
insert
(T entity, InsertOptions options) Insert the given entity applyingWriteOptions
and emit the entity if the insert was applied.<T> Flux<T>
Execute aSELECT
query and convert the resulting items to a stream of entities.<T> Flux<T>
Execute aSELECT
query and convert the resulting items to a stream of entities.<T> Flux<T>
Execute aSELECT
query and convert the resulting items to a stream of entities.<T> Mono<T>
Execute aSELECT
query and convert the resulting item to an entity.<T> Mono<T>
Execute aSELECT
query and convert the resulting item to an entity.<T> Mono<T>
Execute aSELECT
query and convert the resulting item to an entity.<T> Mono<T>
selectOneById
(Object id, Class<T> entityClass) Execute the Select byid
for the givenentityClass
.Execute aSELECT
query with paging and convert the result set to aSlice
of entities.Execute aSELECT
query with paging and convert the result set to aSlice
of entities.Execute aTRUNCATE
query to remove all entities of a given class.Update the queried entities and return true if the update was applied.<T> Mono<T>
update
(T entity) Update the given entity and emit the entity if the update was applied.<T> Mono<EntityWriteResult<T>>
update
(T entity, UpdateOptions options) Update the given entity applyingWriteOptions
and emit the entity if the update was applied.Methods inherited from interface org.springframework.data.cassandra.core.ReactiveDeleteOperation
delete
Methods inherited from interface org.springframework.data.cassandra.core.ReactiveInsertOperation
insert
Methods inherited from interface org.springframework.data.cassandra.core.ReactiveSelectOperation
query
Methods inherited from interface org.springframework.data.cassandra.core.ReactiveUpdateOperation
update
-
Method Details
-
batchOps
Returns a newReactiveCassandraBatchOperations
usingBatchType.LOGGED
. EachReactiveCassandraBatchOperations
instance can be executed only once, so you need to obtain newReactiveCassandraBatchOperations
instances for each batch.- Returns:
- a new
ReactiveCassandraBatchOperations
associated with the given entity class. - Since:
- 2.1
- See Also:
-
batchOps
Returns a newReactiveCassandraBatchOperations
. EachReactiveCassandraBatchOperations
instance can be executed only once, so you need to obtain newReactiveCassandraBatchOperations
instances for each batch.- Parameters:
batchType
- must not be null.- Returns:
- a new
ReactiveCassandraBatchOperations
associated with the given entity class. - Since:
- 3.2.6
-
getReactiveCqlOperations
ReactiveCqlOperations getReactiveCqlOperations()Expose the underlyingReactiveCqlOperations
to allow CQL operations.- Returns:
- the underlying
ReactiveCqlOperations
. - See Also:
-
getConverter
CassandraConverter getConverter()Returns the underlyingCassandraConverter
.- Returns:
- the underlying
CassandraConverter
.
-
select
Execute aSELECT
query and convert the resulting items to a stream of entities.- Parameters:
cql
- must not be null.entityClass
- The entity type must not be null.- Returns:
- the converted results
- Throws:
DataAccessException
- if there is any problem issuing the execution.
-
selectOne
Execute aSELECT
query and convert the resulting item to an entity.- Parameters:
cql
- must not be null.entityClass
- The entity type must not be null.- Returns:
- the result object returned by the action or
Mono.empty()
- Throws:
DataAccessException
- if there is any problem issuing the execution.
-
select
<T> Flux<T> select(com.datastax.oss.driver.api.core.cql.Statement<?> statement, Class<T> entityClass) throws DataAccessException Execute aSELECT
query and convert the resulting items to a stream of entities.- Parameters:
statement
- must not be null.entityClass
- The entity type must not be null.- Returns:
- the result objects returned by the action.
- Throws:
DataAccessException
- if there is any problem issuing the execution.
-
slice
<T> Mono<Slice<T>> slice(com.datastax.oss.driver.api.core.cql.Statement<?> statement, Class<T> entityClass) throws DataAccessException Execute aSELECT
query with paging and convert the result set to aSlice
of entities. A sliced query translates the effectivefetch size
to the page size.- Parameters:
statement
- the CQL statement, must not be null.entityClass
- The entity type must not be null.- Returns:
- the result object returned by the action or
Mono.just(Object)
of an emptySlice
. - Throws:
DataAccessException
- if there is any problem executing the query.- Since:
- 2.1
-
selectOne
<T> Mono<T> selectOne(com.datastax.oss.driver.api.core.cql.Statement<?> statement, Class<T> entityClass) throws DataAccessException Execute aSELECT
query and convert the resulting item to an entity.- Parameters:
statement
- must not be null.entityClass
- The entity type must not be null.- Returns:
- the result object returned by the action or
Mono.empty()
- Throws:
DataAccessException
- if there is any problem issuing the execution.
-
execute
Mono<ReactiveResultSet> execute(com.datastax.oss.driver.api.core.cql.Statement<?> statement) throws DataAccessException Execute the given CassandraStatement
. Any errors that result from executing this command will be converted into Spring's DAO exception hierarchy.- Parameters:
statement
- a CassandraStatement
, must not be null.- Returns:
- the
ReactiveResultSet
. - Throws:
DataAccessException
- if there is any problem issuing the execution.- Since:
- 3.2
-
select
Execute aSELECT
query and convert the resulting items to a stream of entities.- Parameters:
query
- must not be null.entityClass
- The entity type must not be null.- Returns:
- the result objects returned by the action.
- Throws:
DataAccessException
- if there is any problem issuing the execution.
-
slice
Execute aSELECT
query with paging and convert the result set to aSlice
of entities.- Parameters:
query
- the query object used to create a CQL statement, must not be null.entityClass
- The entity type must not be null.- Returns:
- the result object returned by the action or
Mono.just(Object)
of an emptySlice
. - Throws:
DataAccessException
- if there is any problem executing the query.- Since:
- 2.1
- See Also:
-
selectOne
Execute aSELECT
query and convert the resulting item to an entity.- Parameters:
query
- must not be null.entityClass
- The entity type must not be null.- Returns:
- the result object returned by the action or
Mono.empty()
. - Throws:
DataAccessException
- if there is any problem issuing the execution.
-
update
Update the queried entities and return true if the update was applied.- Parameters:
query
- must not be null.update
- must not be null.entityClass
- The entity type must not be null.- Throws:
DataAccessException
- if there is any problem executing the query.
-
delete
Remove entities (rows)/columns from the table byQuery
.- Parameters:
query
- must not be null.entityClass
- The entity type must not be null.- Returns:
- true if the deletion was applied.
- Throws:
DataAccessException
- if there is any problem issuing the execution.
-
count
Returns the number of rows for the given entity class.- Parameters:
entityClass
-type
of the entity; must not be null.- Returns:
- the number of existing entities.
- Throws:
DataAccessException
- if any problem occurs while executing the query.
-
count
Returns the number of rows for the given entity class applyingQuery
. This overridden method allows users to further refine the selection criteria using aQuery
predicate to determine how many entities of the giventype
match the criteria.- Parameters:
query
- user-defined countQuery
to execute; must not be null.entityClass
-type
of the entity; must not be null.- Returns:
- the number of existing entities.
- Throws:
DataAccessException
- if any problem occurs while executing the query.- Since:
- 2.1
-
exists
Determine whether a row ofentityClass
with the givenid
exists.- Parameters:
id
- Id value. For single primary keys it's the plain value. For composite primary keys either, it's an instance of eitherPrimaryKeyClass
orMapId
. Must not be null.entityClass
-type
of the entity; must not be null.- Returns:
- true if the object exists.
- Throws:
DataAccessException
- if any problem occurs while executing the query.
-
exists
Determine whether the result forentityClass
Query
yields at least one row.- Parameters:
query
- user-defined existsQuery
to execute; must not be null.entityClass
-type
of the entity; must not be null.- Returns:
- true if the object exists.
- Throws:
DataAccessException
- if any problem occurs while executing the query.- Since:
- 2.1
-
selectOneById
Execute the Select byid
for the givenentityClass
.- Parameters:
id
- the Id value. For single primary keys it's the plain value. For composite primary keys either thePrimaryKeyClass
orMapId
. Must not be null.entityClass
- The entity type must not be null.- Returns:
- the result object returned by the action or
Mono.empty()
- Throws:
DataAccessException
- if there is any problem issuing the execution.
-
insert
Insert the given entity and emit the entity if the insert was applied.- Parameters:
entity
- The entity to insert, must not be null.- Returns:
- the inserted entity.
- Throws:
DataAccessException
- if there is any problem issuing the execution.
-
insert
Insert the given entity applyingWriteOptions
and emit the entity if the insert was applied.- Parameters:
entity
- The entity to insert, must not be null.options
- must not be null.- Returns:
- the
EntityWriteResult
for this operation. - Throws:
DataAccessException
- if there is any problem issuing the execution.- See Also:
-
update
Update the given entity and emit the entity if the update was applied.- Parameters:
entity
- The entity to update, must not be null.- Returns:
- the updated entity.
- Throws:
DataAccessException
- if there is any problem issuing the execution.
-
update
Update the given entity applyingWriteOptions
and emit the entity if the update was applied.- Parameters:
entity
- The entity to update, must not be null.options
- must not be null.- Returns:
- the
EntityWriteResult
for this operation. - Throws:
DataAccessException
- if there is any problem issuing the execution.- See Also:
-
delete
Delete the given entity and emit the entity if the delete statement was applied.- Parameters:
entity
- must not be null.- Returns:
- the deleted entity.
- Throws:
DataAccessException
- if there is any problem issuing the execution.
-
delete
Delete the given entity applyingQueryOptions
and emit the entity if the delete statement was applied.- Parameters:
entity
- must not be null.options
- must not be null.- Returns:
- the
WriteResult
for this operation. - Throws:
DataAccessException
- if there is any problem issuing the execution.- See Also:
-
delete
Delete the given entity applyingQueryOptions
and emit the entity if the delete statement was applied.- Parameters:
entity
- must not be null.options
- must not be null.- Returns:
- the
WriteResult
for this operation. - Throws:
DataAccessException
- if there is any problem issuing the execution.- Since:
- 2.2
- See Also:
-
deleteById
Remove the given object from the table by id.- Parameters:
id
- the Id value. For single primary keys it's the plain value. For composite primary keys either thePrimaryKeyClass
orMapId
. Must not be null.entityClass
- The entity type must not be null.- Returns:
- true if the deletion was applied.
- Throws:
DataAccessException
- if there is any problem issuing the execution.
-
truncate
Execute aTRUNCATE
query to remove all entities of a given class.- Parameters:
entityClass
- The entity type must not be null.- Throws:
DataAccessException
- if there is any problem issuing the execution.
-