use of com.datastax.driver.core.ResultSetFuture in project jnosql-diana-driver by eclipse.
the class DefaultCassandraColumnFamilyManagerAsync method insert.
@Override
public void insert(ColumnEntity entity, Consumer<ColumnEntity> consumer) {
requireNonNull(entity, "entity is required");
requireNonNull(consumer, "consumer is required");
Insert insert = QueryUtils.insert(entity, keyspace, session);
ResultSetFuture resultSetFuture = session.executeAsync(insert);
resultSetFuture.addListener(() -> consumer.accept(entity), executor);
}
use of com.datastax.driver.core.ResultSetFuture in project jnosql-diana-driver by eclipse.
the class DefaultCassandraColumnFamilyManagerAsync method cql.
@Override
public void cql(String query, Consumer<List<ColumnEntity>> consumer) throws ExecuteAsyncQueryException, NullPointerException {
requireNonNull(query, "query is required");
requireNonNull(consumer, "consumer is required");
ResultSetFuture resultSet = session.executeAsync(query);
CassandraReturnQueryAsync executeAsync = new CassandraReturnQueryAsync(resultSet, consumer);
resultSet.addListener(executeAsync, executor);
}
use of com.datastax.driver.core.ResultSetFuture in project jnosql-diana-driver by eclipse.
the class DefaultCassandraColumnFamilyManagerAsync method save.
@Override
public void save(ColumnEntity entity, ConsistencyLevel level, Consumer<ColumnEntity> callBack) throws ExecuteAsyncQueryException, UnsupportedOperationException {
requireNonNull(entity, "entity is required");
requireNonNull(callBack, "consumer is required");
requireNonNull(level, "ConsistencyLevel is required");
Insert insert = QueryUtils.insert(entity, keyspace, session);
insert.setConsistencyLevel(level);
ResultSetFuture resultSetFuture = session.executeAsync(insert);
resultSetFuture.addListener(() -> callBack.accept(entity), executor);
}
use of com.datastax.driver.core.ResultSetFuture in project jnosql-diana-driver by eclipse.
the class DefaultCassandraColumnFamilyManagerAsync method save.
@Override
public void save(ColumnEntity entity, Duration ttl, ConsistencyLevel level, Consumer<ColumnEntity> callBack) throws ExecuteAsyncQueryException, UnsupportedOperationException {
requireNonNull(entity, "entity is required");
requireNonNull(callBack, "consumer is required");
requireNonNull(level, "level is required");
Insert insert = QueryUtils.insert(entity, keyspace, session);
insert.setConsistencyLevel(level);
insert.using(QueryBuilder.ttl((int) ttl.getSeconds()));
ResultSetFuture resultSetFuture = session.executeAsync(insert);
resultSetFuture.addListener(() -> callBack.accept(entity), executor);
}
use of com.datastax.driver.core.ResultSetFuture in project jnosql-diana-driver by eclipse.
the class DefaultCassandraColumnFamilyManagerAsync method delete.
@Override
public void delete(ColumnDeleteQuery query, Consumer<Void> consumer) {
requireNonNull(query, "query is required");
requireNonNull(consumer, "consumer is required");
BuiltStatement delete = QueryUtils.delete(query, keyspace);
ResultSetFuture resultSetFuture = session.executeAsync(delete);
resultSetFuture.addListener(() -> consumer.accept(null), executor);
}
Aggregations