cassandra-user mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From samal <samalgo...@gmail.com>
Subject Re: Setting Key Validation Class
Date Mon, 05 Dec 2011 16:58:45 GMT
key_validation_class is different from validation_class
validation are BytesType by default.

key_valdation_class => key
default_validation_class=>column_values
comparator=>column_name

default_validation_class is global scope of validation_class


On Mon, Dec 5, 2011 at 10:10 PM, Dinusha Dilrukshi
<sdddilrukshi@gmail.com>wrote:

> Hi,
>
> I am using apache-cassandra-1.0.0 and I tried to insert/retrieve data in a
> column family using cassandra-jdbc program.
> Here is how I created 'USER' column family using cassandra-cli.
>
> create column family USER with comparator=UTF8Type
> and column_metadata=[{column_name: user_id, validation_class: UTF8Type,
> index_type: KEYS},
> {column_name: username, validation_class: UTF8Type, index_type: KEYS},
> {column_name: password, validation_class: UTF8Type}];
>
> But, when i try to insert data to USER column family it gives the error
> "java.sql.SQLException: Mismatched types: java.lang.String cannot be cast
> to java.nio.ByteBuffer".
>
> Since I have set user_id as a KEY and it's validation_class as UTF8Type, I
> was expected Key Validation Class as UTF8Type.
> But when I look at the meta-data of USER column family it shows as "Key
> Validation Class: org.apache.cassandra.db.marshal.BytesType" which has
> cause for the above error.
>
> When I created USER column family as follows, it solves the above issue.
>
> create column family USER with comparator=UTF8Type and
> key_validation_class=UTF8Type
> and column_metadata=[{column_name: user_id, validation_class: UTF8Type,
> index_type: KEYS},
> {column_name: username, validation_class: UTF8Type, index_type: KEYS},
> {column_name: password, validation_class: UTF8Type}];
>
> Do we always need to define *key_validation_class* as in the above query
> ? Isn't it not enough to add validation classes for each column ?
>
> Regards,
> ~Dinusha~
>
>

Mime
View raw message