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.jav
a:124)
        at 
org.apache.cassandra.cql.jdbc.HandleObjects.makeBytes(HandleObjects.java:391
)
        at 
org.apache.cassandra.cql.jdbc.CassandraPreparedStatement.setObject(Cassandra
PreparedStatement.java:351)
        at 
org.apache.cassandra.cql.jdbc.CassandraPreparedStatement.setObject(Cassandra
PreparedStatement.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


Reply via email to