use of org.springframework.data.cassandra.core.mapping.event.BeforeDeleteEvent in project spring-data-cassandra by spring-projects.
the class ReactiveCassandraTemplate method truncate.
/* (non-Javadoc)
* @see org.springframework.data.cassandra.core.ReactiveCassandraOperations#truncate(java.lang.Class)
*/
@Override
public Mono<Void> truncate(Class<?> entityClass) {
Assert.notNull(entityClass, "Entity type must not be null");
CqlIdentifier tableName = getTableName(entityClass);
Truncate truncate = QueryBuilder.truncate(tableName);
SimpleStatement statement = truncate.build();
Mono<Boolean> result = doExecute(statement, ReactiveResultSet::wasApplied).doOnSubscribe(it -> maybeEmitEvent(new BeforeDeleteEvent<>(statement, entityClass, tableName)));
return result.doOnNext(it -> maybeEmitEvent(new AfterDeleteEvent<>(statement, entityClass, tableName))).then();
}
use of org.springframework.data.cassandra.core.mapping.event.BeforeDeleteEvent in project spring-data-cassandra by spring-projects.
the class ReactiveCassandraTemplate method deleteById.
/* (non-Javadoc)
* @see org.springframework.data.cassandra.core.ReactiveCassandraOperations#deleteById(java.lang.Object, java.lang.Class)
*/
@Override
public Mono<Boolean> deleteById(Object id, Class<?> entityClass) {
Assert.notNull(id, "Id must not be null");
Assert.notNull(entityClass, "Entity type must not be null");
CassandraPersistentEntity<?> entity = getRequiredPersistentEntity(entityClass);
CqlIdentifier tableName = entity.getTableName();
StatementBuilder<Delete> builder = getStatementFactory().deleteById(id, entity, tableName);
SimpleStatement delete = builder.build();
Mono<Boolean> result = doExecute(delete, ReactiveResultSet::wasApplied).doOnSubscribe(it -> maybeEmitEvent(new BeforeDeleteEvent<>(delete, entityClass, tableName)));
return result.doOnNext(it -> maybeEmitEvent(new AfterDeleteEvent<>(delete, entityClass, tableName)));
}
use of org.springframework.data.cassandra.core.mapping.event.BeforeDeleteEvent in project spring-data-cassandra by spring-projects.
the class ReactiveCassandraTemplate method doDelete.
Mono<WriteResult> doDelete(Query query, Class<?> entityClass, CqlIdentifier tableName) {
StatementBuilder<Delete> builder = getStatementFactory().delete(query, getRequiredPersistentEntity(entityClass), tableName);
SimpleStatement delete = builder.build();
Mono<WriteResult> writeResult = doExecuteAndFlatMap(delete, ReactiveCassandraTemplate::toWriteResult).doOnSubscribe(it -> maybeEmitEvent(new BeforeDeleteEvent<>(delete, entityClass, tableName)));
return writeResult.doOnNext(it -> maybeEmitEvent(new AfterDeleteEvent<>(delete, entityClass, tableName)));
}
Aggregations