我在cassandra键空间中有一列是timeuuid类型的.当我尝试从
java代码插入reocord时(使用DataStax java driver1.0.3).我得到以下异常
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)
这是我的示例代码:
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()));
我也尝试使用UUIDs.timeBased()而不是now().但我得到同样的例外.
有关如何插入/读取timeuuid数据类型的任何帮助将不胜感激.
最佳答案 我创造了错误
id uuid
这就是为什么当我尝试在uuid类型字段中插入timeuuid时,我得到了那个例外.
现在我已将id的类型更改为timeuuid,一切正常.