How to insert timeuuid into cassandra using datastax java driver OR Incorrect version for TimeUUID

I have one column in the cassandra keyspace that is of type timeuuid. When I try to insert a record from java code (using DataStax java driver1.0.3). I get the following exception

com.datastax.driver.core.exceptions.InvalidQueryException: Invalid version for TimeUUID type.
    at com.datastax.driver.core.exceptions.InvalidQueryException.copy(InvalidQueryException.java:35)
    at com.datastax.driver.core.ResultSetFuture.extractCauseFromExecutionException(ResultSetFuture.java:269)
    at com.datastax.driver.core.ResultSetFuture.getUninterruptibly(ResultSetFuture.java:183)
    at com.datastax.driver.core.Session.execute(Session.java:111)

Here is my sample code:

PreparedStatement statement = session.prepare("INSERT INTO keyspace:table " +
            "(id, subscriber_id, transaction_id) VALUES (now(), ?, ?);");

BoundStatement boundStatement = new BoundStatement(statement);

Session.execute(boundStatement.bind(UUID.fromString(requestData.getsubscriberId()), 
            requestData.getTxnId()));

I also tried using UUIDs.timeBased()instead now(). But I get the same exception.

Any input / read help from timeuuiddatatype would be appreciated.

+4
source share
1 answer

By mistake, I created

id  uuid

That is why when I try to insert timeuuidinto the type field uuid, I got this exception.

id timeuuid, .

+2

All Articles