首页 > 解决方案 > Cassandra InvalidQueryException:键可能不为空

问题描述

InvalidQueryException:使用 DataStax Astra Cassandra DB 的 Java 驱动程序时,键可能不为空。

我 100% 确定我的 partitionKey 或 clusteringColumns 不为空。有人能告诉我除此之外这个错误意味着什么吗?

相同的代码在该异常意味着什么之前工作了 1 小时?

标签: javacassandradatastax-astra

解决方案


谢谢大家,但我自己找到了。

我把 a 写成了Longan之后ByteBuffer就没有用flip()了。

 public static ByteBuffer toBB(Long x) {
    ByteBuffer bb = ByteBuffer.allocate(Long.BYTES);
    if (x == null) {
        return null;
    }
    bb.putLong(x);
    bb.flip(); //Added this line here and it works
    return bb;
}

推荐阅读