4
我在cassandra keyspace中有一列是timeuuid類型的。當我嘗試從java代碼插入一個reocord時(使用DataStax java driver1.0.3)。我得到下面的異常如何將timeuuid插入到使用datastax java驅動程序的cassandra中或者TimeUUID的無效版本
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
數據類型讀取任何幫助將不勝感激。