kundera icon indicating copy to clipboard operation
kundera copied to clipboard

can UUID type do well in kundera2.3 by using cassandra 1.2?

Open zhouhero opened this issue 13 years ago • 11 comments

when i use UUID in the table, error happened like fellow,

can anyone help me?

com.impetus.kundera.KunderaException: org.scale7.cassandra.pelops.exceptions.InvalidRequestException: Not enough bytes to read value of component 0

zhouhero avatar Jan 29 '13 09:01 zhouhero

Hi, I would suggest you to change your clientFactory from PelopsFactory to ThriftFactory. Pelops will be deprecated in later stages.

Yes UUID is supported by Kundera. Have a look at: https://github.com/impetus-opensource/Kundera/blob/trunk/kundera-cassandra/src/test/java/com/impetus/client/crud/datatypes/StudentCassandraUUIDTest.java

Package: https://github.com/impetus-opensource/Kundera/blob/trunk/kundera-cassandra/src/test/java/com/impetus/client/crud/datatypes/

contains test case for all supported data types.

Cheers, -Vivek

mevivs avatar Jan 29 '13 10:01 mevivs

when i change the driver to ThriftFactory, the error info changed.

Caused by: com.impetus.kundera.KunderaException: InvalidRequestException(why:Not enough bytes to read value of component 0) at com.impetus.client.cassandra.thrift.ThriftClient.onPersist(ThriftClient.java:165) at com.impetus.kundera.client.ClientBase.persist(ClientBase.java:83) at com.impetus.client.cassandra.thrift.ThriftClient.persist(ThriftClient.java:130) at com.impetus.kundera.lifecycle.states.ManagedState.handleFlush(ManagedState.java:193) at com.impetus.kundera.graph.Node.flush(Node.java:525) at com.impetus.kundera.persistence.PersistenceDelegator.flush(PersistenceDelegator.java:422) at com.impetus.kundera.persistence.PersistenceDelegator.persist(PersistenceDelegator.java:167)

at com.impetus.kundera.persistence.EntityManagerImpl.persist(EntityManagerImpl.java:214)

zhouhero avatar Jan 29 '13 10:01 zhouhero

※my db: cassandra 1.2 + kundera2.3

※my table: create columnfamily test1 (id timeuuid primary key, url text, userid uuid, datetime timestamp, linkcounts int)

※my entity @Entity @Table(name="test1", schema="XXX@cassandra_pu") public class Test1Entity { @Id @Column(name = "id") private UUID key;

@Column(name = "userid")
private UUID userid;

@Column(name = "url")
private String url;

@Column(name = "datetime")
private Timestamp datetime;

@Column(name = "linkcounts")
private int linkcounts;


public Test1Entity() {
}

public UUID getKey()
{
    return key;
}
public void setKey(UUID key)
{
    this.key = key;
}

public UUID getUserid()
{
    return userid;
}
public void setUserid(UUID userid)
{
    this.userid = userid;
}

public String getUrl()
{
    return url;
}
public void setUrl(String url)
{
    this.url = url;
}
public Timestamp getDatetime()
{
    return datetime;
}
public void setDatetime(Timestamp datetime)
{
    this.datetime = datetime;
}

public int getLinkcounts()
{
    return linkcounts;
}
public void setLinkcounts(int linkcounts)
{
    this.linkcounts = linkcounts;
}

}

zhouhero avatar Jan 29 '13 10:01 zhouhero

the error hanppend when i save data by entitymanager.persist() method.

zhouhero avatar Jan 29 '13 10:01 zhouhero

Create your column family from Cassandra-cli as:

create column family test1 with key_validation_class = 'TimeUUIDType' and comparator = 'UTF8Type' and column_metadata=[{column_name:url, validation_class: UTF8Type},{column_name:userid, validation_class: UUIDType},{column_name:datetime, validation_class: DateType}, {column_name:userid, validation_class: IntegerType}];

Let me know, if it works for you.

mevivs avatar Jan 29 '13 10:01 mevivs

Thrift API by default read an extra column for any column family created via CQL. CQL binary protocol is designed in 1.2 but still no ready-to-use API available for use. We are working to enable CQL binary protocol in Kundera(Probably in 2.4)

-Vivek

mevivs avatar Jan 29 '13 10:01 mevivs

yes , it worked well when i use Cassandra-cli creating the table!

by the way, we are create over 200 tables by using cql3 now, if you can add CQL binary protocol in Kundera(2.4), it will help me grateful!

zhouhero avatar Jan 29 '13 10:01 zhouhero

will do. We had accessed it earlier as well. As of now none of client provides it. Even datastax java-driver is still in beta and may released in march-april 2012. Also there are other issues involved around it, like connection pooling, and other stuff which Kundera provides. So that's why 2.4 will have it.

Cassandra's main philosophy was to be schema-less and CQL3.0 is all about schema. That i would consider a major shift and personally would want Cassandra to behave correctly for such interoperability issue, which it is not unfortunately.

-Vivek

mevivs avatar Jan 29 '13 10:01 mevivs

Shall we close on this? I will post an update once CQL binary protocol is supported in Kundera.

-Vivek

mevivs avatar Jan 29 '13 11:01 mevivs

Yes, thanks you explanations! It seems that Kundera 2.4 will do better than 2.3. I think we can use "kundera 2.3 + cassandra1.8" until 2.4 release.

zhouhero avatar Jan 29 '13 11:01 zhouhero

You can use Cassandra 1.2 and Kundera 2.3, Thrift APIs have been migrated to new version and as well CQL invocation via thrift! CQL binary protocol is what we are targetting for 2.4

-Vivek

mevivs avatar Jan 29 '13 11:01 mevivs