Return-Path: X-Original-To: apmail-cassandra-user-archive@www.apache.org Delivered-To: apmail-cassandra-user-archive@www.apache.org Received: from mail.apache.org (hermes.apache.org [140.211.11.3]) by minotaur.apache.org (Postfix) with SMTP id BDC237DAD for ; Mon, 5 Dec 2011 16:47:08 +0000 (UTC) Received: (qmail 14376 invoked by uid 500); 5 Dec 2011 16:47:06 -0000 Delivered-To: apmail-cassandra-user-archive@cassandra.apache.org Received: (qmail 14344 invoked by uid 500); 5 Dec 2011 16:47:06 -0000 Mailing-List: contact user-help@cassandra.apache.org; run by ezmlm Precedence: bulk List-Help: List-Unsubscribe: List-Post: List-Id: Reply-To: user@cassandra.apache.org Delivered-To: mailing list user@cassandra.apache.org Received: (qmail 14336 invoked by uid 99); 5 Dec 2011 16:47:06 -0000 Received: from nike.apache.org (HELO nike.apache.org) (192.87.106.230) by apache.org (qpsmtpd/0.29) with ESMTP; Mon, 05 Dec 2011 16:47:06 +0000 X-ASF-Spam-Status: No, hits=-0.7 required=5.0 tests=FREEMAIL_FROM,RCVD_IN_DNSWL_LOW,SPF_PASS X-Spam-Check-By: apache.org Received-SPF: pass (nike.apache.org: domain of the.wa.syndrome@gmail.com designates 209.85.216.51 as permitted sender) Received: from [209.85.216.51] (HELO mail-qw0-f51.google.com) (209.85.216.51) by apache.org (qpsmtpd/0.29) with ESMTP; Mon, 05 Dec 2011 16:47:00 +0000 Received: by qadb12 with SMTP id b12so3463943qad.10 for ; Mon, 05 Dec 2011 08:46:39 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=gamma; h=mime-version:in-reply-to:references:date:message-id:subject:from:to :content-type:content-transfer-encoding; bh=wlJoqcE7Xv6t1wvQIy3mQQ2TwUwKFOnyyD0+YcGsw64=; b=VrALZ4SJVf7ZZfbbdqvp4HPMgRD7kNmD+zjkOicpkVp/SHmEItwaw6xARIXclOUa3z RueBqh1mQnSYIycw+87FWTOsLq/giXhehEGLHJE6NhGIVQjCa5mqB/yk+8+iOpSGkp3t pIFEsfhU/Z7QV/VPWbz0mao/MmEJohDNmb0iM= MIME-Version: 1.0 Received: by 10.224.217.66 with SMTP id hl2mr8634943qab.84.1323103599476; Mon, 05 Dec 2011 08:46:39 -0800 (PST) Received: by 10.229.34.197 with HTTP; Mon, 5 Dec 2011 08:46:39 -0800 (PST) In-Reply-To: References: Date: Mon, 5 Dec 2011 16:46:39 +0000 Message-ID: Subject: Re: Setting Key Validation Class From: =?UTF-8?Q?Filipe_Gon=C3=A7alves?= To: user@cassandra.apache.org Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: quoted-printable X-Virus-Checked: Checked by ClamAV on apache.org Cassandra's data model is NOT table based. The key is not a column, it is a separate value. "index_type: KEYS" means you are creating an index on that column, and that index can only be acessed in an equality query ( column =3D x ). You should probably read http://www.datastax.com/docs/1.0/ddl/index first. 2011/12/5 Dinusha Dilrukshi : > Hi, > > I am using=C2=A0apache-cassandra-1.0.0 and I tried to insert/retrieve=C2= =A0data 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=3DUTF8Type > and column_metadata=3D[{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=C2=A0validation_class as UTF8T= ype, I > was expected=C2=A0Key Validation Class as=C2=A0UTF8Type. > 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 ca= use > for the above error. > > When I created USER column family as follows, it solves the above issue. > > create column family USER with comparator=3DUTF8Type and > key_validation_class=3DUTF8Type > and column_metadata=3D[{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=C2=A0key_validation_class=C2=A0as in the abov= e query ? > Isn't it not enough to add validation classes for each column ? > > Regards, > ~Dinusha~ > --=20 Filipe Gon=C3=A7alves