javaspring-bootcassandracqldatastax-java-driver

How do I update a column value and set a TTL for the whole row?


i'm trying to update a column value (not key column) and to set new TTL for the whole row. But when i execute the generated statement, only column ttl was updates and the other columns remain with the original, producing NULL values in future reads.

My app was written in Java and using datastax for querying, and the function for generating the statement is something like this.

private Statement updateLastActivityStatement(int ttl, Long ts){
    return QueryBuilder.update(KEY_SPACE, TABLE_NAME)
        .with(QueryBuilder.set(LAST_ACTIVITY, ts))
        .where(QueryBuilder.eq(ENTRY_ID, userA))
        .and(QueryBuilder.eq(ID, userB))
        .using(QueryBuilder.ttl(ttl));
}

Solution

  • TTL is bound to a specific cell, so when you're updating only specific columns, then only them are updated. To update everything, you need to update all values