Spring Data Cassandra - Retrieve Rows Affected

292 Views Asked by At

Is it possible get the rows affected in the Update Statement?

public void removeCountry(String id,int version) throws VersionException {
    log.debug("Update row"+id);
    try {
        Update update = QueryBuilder.update("country");
        update.setConsistencyLevel(ConsistencyLevel.ONE);
        update.with(QueryBuilder.set("destroyed", true));
        update.where(QueryBuilder.eq("id",id));
        update.where(QueryBuilder.eq("version",version));
        cassandraOperations.execute(update);
        //How to I know if the row was updated
        int rows = 0;//complete
        if (rows==0) throw new VersionException("Row does not been updated yet);
    } catch (Exception e) {
        log.error(e.getMessage(),e);
    }
}

I am newbie with Cassandra, so I dont know if I can do that like a the JDBC Operation.

1

There are 1 best solutions below

0
John Blum On BEST ANSWER

As I suspected, given the distributed nature of Cassandra with varying levels of consistency, the short answer is NO.

Others have posted similar questions on SO before, for example...

How to know affected rows in Cassandra(CQL)?