我在 cassandra 键空间中有一个类型为 timeuuid 的列。当我尝试从 java 代码中插入记录时(使用 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
数据类型的帮助将不胜感激。