Search in sources :

Example 16 with BoundStatement

use of com.datastax.driver.core.BoundStatement in project cassandra-driver-mapping by valchkou.

the class MappingSession method updateValues.

/**
     * Update values with options.
     * 
     * @param id Primary Key
     * @param class Entity.class
     * @param propertyNames Array of properties to update
     * @param value array of values to update
     */
public void updateValues(Object id, Class<?> clazz, String[] propertyNames, Object[] values, WriteOptions options) {
    maybeSync(clazz);
    BoundStatement bs = MappingBuilder.prepareUpdateValues(id, clazz, propertyNames, values, options, keyspace, session);
    execute(bs);
}
Also used : BoundStatement(com.datastax.driver.core.BoundStatement)

Example 17 with BoundStatement

use of com.datastax.driver.core.BoundStatement in project cassandra-driver-mapping by valchkou.

the class MappingSession method get.

/**
     * Get Entity by Id(Primary Key)
     * 
     * @param class Entity.class
     * @param id primary key
     * @param options ReadOptions
     * @return Entity instance or null
     */
public <T> T get(Class<T> clazz, Object id, ReadOptions options) {
    maybeSync(clazz);
    BoundStatement bs = MappingBuilder.prepareSelect(clazz, id, options, keyspace, session);
    if (bs != null) {
        ResultSet rs = session.execute(bs);
        List<T> all = getFromResultSet(clazz, rs);
        if (all.size() > 0) {
            return all.get(0);
        }
    }
    return null;
}
Also used : ResultSet(com.datastax.driver.core.ResultSet) BoundStatement(com.datastax.driver.core.BoundStatement)

Example 18 with BoundStatement

use of com.datastax.driver.core.BoundStatement in project cassandra-driver-mapping by valchkou.

the class MappingSession method deleteValueAsync.

/**
     * Asynchronously Delete value for an individual property
     * 
     * @param id Primary Key
     * @param class Entity.class
     * @param propertyName Entity property
     * @return ResultSetFuture.
     */
public ResultSetFuture deleteValueAsync(Object id, Class<?> clazz, String propertyName) {
    maybeSync(clazz);
    BoundStatement bs = MappingBuilder.prepareDelete(id, clazz, propertyName, keyspace, session);
    return executeAsync(bs);
}
Also used : BoundStatement(com.datastax.driver.core.BoundStatement)

Example 19 with BoundStatement

use of com.datastax.driver.core.BoundStatement in project cassandra-driver-mapping by valchkou.

the class MappingSession method updateValue.

/**
     * Replace existing value with a new one.
     * 
     * @param id Primary Key
     * @param class Entity.class
     * @param propertyName Entity property
     * @param value new value
     * @param options WriteOptions
     */
public void updateValue(Object id, Class<?> clazz, String propertyName, Object value, WriteOptions options) {
    maybeSync(clazz);
    BoundStatement bs = MappingBuilder.prepareUpdateValue(id, clazz, propertyName, value, options, keyspace, session);
    execute(bs);
}
Also used : BoundStatement(com.datastax.driver.core.BoundStatement)

Example 20 with BoundStatement

use of com.datastax.driver.core.BoundStatement in project cassandra-driver-mapping by valchkou.

the class MappingSession method deleteValue.

/**
     * Delete value for an individual property
     * 
     * @param id Primary Key
     * @param class Entity.class
     * @param propertyName Entity property
     */
public void deleteValue(Object id, Class<?> clazz, String propertyName) {
    maybeSync(clazz);
    BoundStatement bs = MappingBuilder.prepareDelete(id, clazz, propertyName, keyspace, session);
    execute(bs);
}
Also used : BoundStatement(com.datastax.driver.core.BoundStatement)

Aggregations

BoundStatement (com.datastax.driver.core.BoundStatement)39 ResultSet (com.datastax.driver.core.ResultSet)7 ResultSetFuture (com.datastax.driver.core.ResultSetFuture)5 Row (com.datastax.driver.core.Row)5 Test (org.junit.Test)5 PreparedStatement (com.datastax.driver.core.PreparedStatement)4 ArrayList (java.util.ArrayList)4 RegularStatement (com.datastax.driver.core.RegularStatement)3 Session (com.datastax.driver.core.Session)3 ListenableFuture (com.google.common.util.concurrent.ListenableFuture)3 List (java.util.List)3 Map (java.util.Map)3 MetricRegistry (com.codahale.metrics.MetricRegistry)2 Statement (com.datastax.driver.core.Statement)2 ImmutableList (com.google.common.collect.ImmutableList)2 ImmutableSet (com.google.common.collect.ImmutableSet)2 Futures.allAsList (com.google.common.util.concurrent.Futures.allAsList)2 LinkedHashMap (java.util.LinkedHashMap)2 UUID (java.util.UUID)2 ExecutionException (java.util.concurrent.ExecutionException)2