Search in sources :

Example 16 with ResultSetFuture

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);
}
Also used : ResultSetFuture(com.datastax.driver.core.ResultSetFuture) Insert(com.datastax.driver.core.querybuilder.Insert)

Example 17 with ResultSetFuture

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);
}
Also used : ResultSetFuture(com.datastax.driver.core.ResultSetFuture)

Example 18 with ResultSetFuture

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);
}
Also used : ResultSetFuture(com.datastax.driver.core.ResultSetFuture) Insert(com.datastax.driver.core.querybuilder.Insert)

Example 19 with ResultSetFuture

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);
}
Also used : ResultSetFuture(com.datastax.driver.core.ResultSetFuture) Insert(com.datastax.driver.core.querybuilder.Insert)

Example 20 with ResultSetFuture

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);
}
Also used : ResultSetFuture(com.datastax.driver.core.ResultSetFuture) BuiltStatement(com.datastax.driver.core.querybuilder.BuiltStatement)

Aggregations

ResultSetFuture (com.datastax.driver.core.ResultSetFuture)78 Test (org.junit.Test)35 UUID (java.util.UUID)26 ResultSet (com.datastax.driver.core.ResultSet)20 EntityWithCollections (com.datastax.driver.mapping.entity.EntityWithCollections)13 BoundStatement (com.datastax.driver.core.BoundStatement)12 PreparedStatement (com.datastax.driver.core.PreparedStatement)10 ArrayList (java.util.ArrayList)8 Date (java.util.Date)8 Row (com.datastax.driver.core.Row)7 Statement (com.datastax.driver.core.Statement)7 List (java.util.List)6 Session (com.datastax.driver.core.Session)5 Simple (com.datastax.driver.mapping.entity.Simple)5 Cell (com.palantir.atlasdb.keyvalue.api.Cell)5 BigDecimal (java.math.BigDecimal)5 HashSet (java.util.HashSet)5 Result (com.datastax.driver.mapping.Result)4 WriteOptions (com.datastax.driver.mapping.option.WriteOptions)4 Nullable (javax.annotation.Nullable)4