0

I am using kundera 2.4 as my JPA interacton with Cassandra .

Created Column family in cassandra

create column family usageitem  with key_validation_class = 'UTF8Type'
 and comparator = 'UTF8Type' ;

The default validation class assumed by cassandra for a column is BytesType . I want to change it to UTF8Type via jpa entity

I do not want to change the above column definition to

create column family usageitem  with key_validation_class =
 'UTF8Type' and comparator = 'UTF8Type' and default_validation_class =
 'UTF8Type' ;

because i do not want to touch my existing database definition

My JPA entity is looking something like this -

@Entity
@Table(name = "usageitem", schema = "TITAN@TROYUnit")
public class UsageItem {    

@Id
@Column(name="record_id")
private String recordID;

@Column(name="provider_name",columnDefinition="UTF8Type")
private String providerName;

//Setters & Getters ....

}

So how should i specify the validation type of cassandra column value in the above JPA entity to insert data in utf8 or text format ?

ip_x
  • 172
  • 2
  • 6

1 Answers1

0

First, i will suggest to upgrade for 2.6 release.

Second, ideally data type should be in sync with Cassandra data types. if it is BytesType, it should be of type byte or byte.

Also, Can you please share the error you getting if column values are defined as "String" in jpa entity while those are BytesType in Cassandra?

-Vivek

vivek mishra
  • 1,162
  • 8
  • 16
  • Data type for column value can be added or changed in a column family definition at any time (according to cassandra). So in this case there is no need for me to sync with cassandra data type for column value . – ip_x Jul 31 '13 at 03:39
  • I am not facing any runtime error. What i need is that when i view the data of usageitem ( column family ) inserted through above jpa entity in the cassandra-cli console , it should show me in text or utf8 format instead of bytes format – ip_x Jul 31 '13 at 03:51
  • Vivek Mishra , can you specify any means of making a change in JPA entity instead of changing the existing Cassandra db query to insert data of utf8 type in column value – ip_x Jul 31 '13 at 10:46
  • change @Column(name="provider_name",columnDefinition="UTF8Type") private String providerName; as @Column(name="provider_name",columnDefinition="UTF8Type") private byte[] providerName; and persist in byte[], which will be of BytesType in Cassandra. – vivek mishra Jul 31 '13 at 11:47
  • vivek mishra , i'll surely try what you mentioned . – ip_x Aug 02 '13 at 08:41