Pregunta

Can anyone give me a hint as to why this doesn't work? It doesn't seem to set the TTL; the columns are never deleted. Messing around with INSERT INTO in cqlsh does, though, so there's nothing wrong with Cassandra itself.

    StringBuffer cql = new StringBuffer("INSERT INTO ");
    cql.append(getKeyspace());
    cql.append(".taskitems ");
    cql.append(/* long field list */);
    cql.append(" VALUES ");
    cql.append("(?,?,?,?,?,?,?,?,?,?,?,?,?,?,?,?,?,?,?) USING TTL 30");
    //cql.append(getTimeToLive()); // commented out, trying hardcoded value above

    PreparedStatement statement = session.prepare(cql.toString());

    session.execute( statement.bind(
        /* lots o' fields */    
    ));

(Cassandra v2.0.0, driver v1.0.)

¿Fue útil?

Solución

Your problem is due to a driver mis-match between datastax-java-driver and Cassandra (either both should be v1 or both should be v2) - try upgrading datastax-java-driver to v2.

It would also be worth using the datastax-java-driver QueryBuilder, which is less bug-prone than building String queries manually. (The datastax-java-driver v1 QueryBuilder javadocs is here.)

Licenciado bajo: CC-BY-SA con atribución
No afiliado a StackOverflow
scroll top