There is an open ticket for this https://code.google.com/a/apache-extras.org/p/cassandra-jdbc/issues/detail?id=72

Cheers

-----------------
Aaron Morton
Freelance Cassandra Consultant
New Zealand

@aaronmorton

On 3/05/2013, at 1:57 AM, Robert Wille <rwille@footnote.com> 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);
statement.execute();

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(HandleObjects.java:124)
        at org.apache.cassandra.cql.jdbc.HandleObjects.makeBytes(HandleObjects.java:391)
        at org.apache.cassandra.cql.jdbc.CassandraPreparedStatement.setObject(CassandraPreparedStatement.java:351)
        at org.apache.cassandra.cql.jdbc.CassandraPreparedStatement.setObject(CassandraPreparedStatement.java:338)
        at CassandraTest.main(CassandraTest.java:26)

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.

Robert