Search code examples
cassandrahector

Using which Query Implementation to get a row from Cassandra


I want to retrieve a row from Cassandra using column family and row key. However when I using SliceQuery, there is an exception:Caused by: me.prettyprint.hector.api.exceptions.HectorException: Neither column names nor range were set, this is an invalid slice predicate.

Does anyone know whether I have used a wrong Query implementation?


Solution

  • This will give you an entire row:

    SliceQuery query = HFactory.createSliceQuery(_keyspace, _stringSerializer, _stringSerializer, _stringSerializer);
    query.setColumnFamily(columnFamily)
         .setKey(key)
         .setRange("", "", false, Integer.MAX_VALUE);