Search code examples
javacassandradatastax-astra

Cassandra InvalidQueryException: Key may not be empty


InvalidQueryException: Key may not be empty When using the Java Driver for DataStax Astra Cassandra DB.

I'm 100% sure that my partitionKey or my clusteringColumns are not empty. Can someone tell me what this error can mean besides that?

The same code worked 1 hour before what does that exception mean?


Solution

  • Thank you guys but I just found it myself.

    I wrote a Long into an ByteBuffer and didn't use flip() afterwards.

     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;
    }