There is an open ticket for this


Aaron Morton
Freelance Cassandra Consultant
New Zealand


On 3/05/2013, at 1:57 AM, Robert Wille <> wrote:

Just downloaded the latest Cassandra and JDBC driver. When I try to insert UUID's into a column family, I get an exception.

Here's how I created the column family:

CREATE TABLE browse.tree (tree_id UUID PRIMARY KEY, activation_time TIMESTAMP, tree_lock_id INT, sql_publication_id INT);

Here's some code that produces the problem:

UUID uuid = java.util.UUID.randomUUID();
PreparedStatement statement = c.prepareStatement("insert into tree (tree_id) values (?)");
statement.setObject(1, uuid);

And here's the exception I get:

java.sql.SQLNonTransientException: encountered object of class: class java.util.UUID, but only 'String' is supported to map to the various VARCHAR types
        at org.apache.cassandra.cql.jdbc.HandleObjects.makeBadMapping(
        at org.apache.cassandra.cql.jdbc.HandleObjects.makeBytes(
        at org.apache.cassandra.cql.jdbc.CassandraPreparedStatement.setObject(
        at org.apache.cassandra.cql.jdbc.CassandraPreparedStatement.setObject(
        at CassandraTest.main(

I've tried using the string representation, but then it complains saying that it needs to be exactly 16 bytes. I've tried inserting as a byte array of length 16, but I get the same exception as above.

Any help would be appreciated. Thanks.