[ https://issues.apache.org/jira/browse/CASSANDRA-2410?page=com.atlassian.jira.plugin.system.issuetabpanels:all-tabpanel ]
Jonathan Ellis reassigned CASSANDRA-2410: ----------------------------------------- Assignee: Gary Dusbabek > JDBC ResultSet does not honor column value typing for the CF and uses default > validator for all column value types. > ------------------------------------------------------------------------------------------------------------------- > > Key: CASSANDRA-2410 > URL: https://issues.apache.org/jira/browse/CASSANDRA-2410 > Project: Cassandra > Issue Type: Bug > Components: API > Reporter: Rick Shaw > Assignee: Gary Dusbabek > Priority: Minor > Labels: cql > Fix For: 0.8 > > > Assume a CF declared in CQL as : > {code} > CREATE COLUMNFAMILY TestCF(KEY utf8 PRIMARY KEY,description utf8, anumber int) > WITH comparator = ascii AND default_validation = long; > {code} > If the {{ResultSet}} is fetched thusly: > {code} > Statement stmt = con.createStatement(); > ResultSet rs = stmt.executeQuery(query); > String description; > Integer anumber; > while (rs.next()) > { > description = rs.getString(1); > System.out.print("description : "+ description); > anumber = rs.getInt(2); > System.out.print("anumber : "+ anumber); > } > {code} > It will immediately fail with a message of: > {code} > org.apache.cassandra.db.marshal.MarshalException: A long is exactly 8 bytes: > 16 > at org.apache.cassandra.db.marshal.LongType.getString(LongType.java:66) > at org.apache.cassandra.cql.jdbc.TypedColumn.<init>(TypedColumn.java:45) > at > org.apache.cassandra.cql.jdbc.ColumnDecoder.makeCol(ColumnDecoder.java:158) > at > org.apache.cassandra.cql.jdbc.CassandraResultSet.next(CassandraResultSet.java:1073) > at da.access.testing.TestJDBC.selectAll(TestJDBC.java:83) > ... > {code} > It appears that the {{makeCol}} method of {{ColumnDecoder.java}} chooses NOT > to use the {{CfDef}} to look up the possible occurrence of a column? That's > not right. Right? > {code} > /** constructs a typed column */ > public TypedColumn makeCol(String keyspace, String columnFamily, byte[] > name, byte[] value) > { > CfDef cfDef = cfDefs.get(String.format("%s.%s", keyspace, > columnFamily)); > AbstractType comparator = getComparator(keyspace, columnFamily, > Specifier.Comparator, cfDef); > AbstractType validator = getComparator(keyspace, columnFamily, > Specifier.Validator, null); > return new TypedColumn(comparator, name, validator, value); > } > {code} -- This message is automatically generated by JIRA. For more information on JIRA, see: http://www.atlassian.com/software/jira