Cassandra:插入timeuuid错误

4
我有以下表格。
create table test(
         userId varchar,
         notifId timeuuid,
         notification varchar,
         time bigint,read boolean,
         primary key(userId, notifId)) with clustering order by (notifId desc);

我正在运行以下查询:

PreparedStatement   pstmt  = session.prepare("INSERT INTO notifications(userId, notifId, notification, time, read) VALUES(?, now(), ?, ?, ?)");

BoundStatement      boundStatement  = new BoundStatement(pstmt);
        session.execute(boundStatement.bind("123", "hello", new Date().getTime(), false));

我得到了以下错误提示:
Exception in thread "main" com.datastax.driver.core.exceptions.InvalidQueryException: Type error: cannot assign result of function now (type timeuuid) to notifid (type 'org.apache.cassandra.db.marshal.ReversedType(org.apache.cassandra.db.marshal.TimeUUIDType)')
    at com.datastax.driver.core.exceptions.InvalidQueryException.copy(InvalidQueryException.java:35)
    at com.datastax.driver.core.ResultSetFuture.extractCause(ResultSetFuture.java:277)
    at com.datastax.driver.core.Session.toPreparedStatement(Session.java:281)
    at com.datastax.driver.core.Session.prepare(Session.java:172)
    at com.example.cassandra.SimpleClient.loadData(SimpleClient.java:130)
    at com.example.cassandra.SimpleClient.main(SimpleClient.java:214)
Caused by: com.datastax.driver.core.exceptions.InvalidQueryException: Type error: cannot assign result of function now (type timeuuid) to notifid (type 'org.apache.cassandra.db.marshal.ReversedType(org.apache.cassandra.db.marshal.TimeUUIDType)')
    at com.datastax.driver.core.ResultSetFuture.convertException(ResultSetFuture.java:307)

我正在使用Cassandra 1.2.2版本。

2个回答

6

这个类的路径是 import com.datastax.driver.core.utils.UUIDs - ssuperczynski

0

看起来像是一个 bug(类似或与 https://issues.apache.org/jira/browse/CASSANDRA-5472 相同),而且您正在使用相当旧的 Cassandra 版本。我建议您升级到最新的 1.2.x 发布版本,重新测试您的场景并提交问题,如果问题仍然存在。


网页内容由stack overflow 提供, 点击上面的
可以查看英文原文,
原文链接