use of com.datastax.oss.driver.api.querybuilder.truncate.Truncate in project spring-data-cassandra by spring-projects.
the class AsyncCassandraTemplate method truncate.
/* (non-Javadoc)
* @see org.springframework.data.cassandra.core.AsyncCassandraOperations#truncate(java.lang.Class)
*/
@Override
public ListenableFuture<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();
maybeEmitEvent(new BeforeDeleteEvent<>(statement, entityClass, tableName));
ListenableFuture<Boolean> future = doExecute(statement, AsyncResultSet::wasApplied);
future.addCallback(success -> maybeEmitEvent(new AfterDeleteEvent<>(statement, entityClass, tableName)), e -> {
});
return new MappingListenableFutureAdapter<>(future, aBoolean -> null);
}
use of com.datastax.oss.driver.api.querybuilder.truncate.Truncate in project spring-data-cassandra by spring-projects.
the class CassandraTemplate method truncate.
/* (non-Javadoc)
* @see org.springframework.data.cassandra.core.CassandraOperations#truncate(java.lang.Class)
*/
@Override
public 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();
maybeEmitEvent(new BeforeDeleteEvent<>(statement, entityClass, tableName));
doExecute(statement);
maybeEmitEvent(new AfterDeleteEvent<>(statement, entityClass, tableName));
}
use of com.datastax.oss.driver.api.querybuilder.truncate.Truncate 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();
}
Aggregations