Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

byte[] @Column or @Id is not supported with Kundera+CQL #396

Closed
jfgosselin opened this issue Sep 16, 2013 · 9 comments
Closed

byte[] @Column or @Id is not supported with Kundera+CQL #396

jfgosselin opened this issue Sep 16, 2013 · 9 comments
Assignees
Milestone

Comments

@jfgosselin
Copy link

For the following entity :

TABLE test (
key text,
data blob,
PRIMARY KEY (key)
)

@entity
@table(name = "test", schema = "kunderatest@cassandra_pu")
public class Dummy {

@id
private String id;

@column(name = "data")
private byte[] data;

}

I get the following error :

12:25:41,067 ERROR com.impetus.client.cassandra.pelops.PelopsClient: 465 - Error during persist while executing query INSERT INTO "test"("key","data") VALUES('123',[B@75d252d) , Caused by: .
InvalidRequestException(why:line 1:57 mismatched character ')' expecting set null)
at org.apache.cassandra.thrift.Cassandra$execute_cql3_query_result.read(Cassandra.java:37849)
at org.apache.thrift.TServiceClient.receiveBase(TServiceClient.java:78)

@mevivs
Copy link
Collaborator

mevivs commented Sep 16, 2013

Hi,
Can you please provide more details on this? CQL3 does provide some blob conversion function. Did you try executing a native CQL3 query with byte[] ?

-Vivek

@jfgosselin
Copy link
Author

Hi,

No, it wasn't a native query, here's the code:

Map<String, String> propertyMap = new HashMap<String, String>();
propertyMap.put(CassandraConstants.CQL_VERSION, CassandraConstants.CQL_VERSION_3_0);
EntityManagerFactory emf = Persistence.createEntityManagerFactory("cassandra_pu", propertyMap);
EntityManager em = emf.createEntityManager();

Dummy d = new Dummy();
d.setId("123");
d.setData("a blob".getBytes());
em.persist(d);

em.close();
emf.close();

ERROR 2013-09-17 09:41:26,548 [main] com.impetus.client.cassandra.pelops.PelopsClient - Error during persist while executing query INSERT INTO "test"("id","data") VALUES('123',[B@2321b59a) , Caused by: .
InvalidRequestException(why:line 1:57 mismatched character ')' expecting '-')
at org.apache.cassandra.thrift.Cassandra$execute_cql3_query_result.read(Cassandra.java:37849)
at org.apache.thrift.TServiceClient.receiveBase(TServiceClient.java:78)
at org.apache.cassandra.thrift.Cassandra$Client.recv_execute_cql3_query(Cassandra.java:1562)
at org.apache.cassandra.thrift.Cassandra$Client.execute_cql3_query(Cassandra.java:1547)
at com.impetus.client.cassandra.CassandraClientBase.executeCQLQuery(CassandraClientBase.java:1734)
at com.impetus.client.cassandra.pelops.PelopsClient.onPersist(PelopsClient.java:461)
at com.impetus.kundera.client.ClientBase.persist(ClientBase.java:88)
at com.impetus.kundera.lifecycle.states.ManagedState.handleFlush(ManagedState.java:183)
at com.impetus.kundera.graph.Node.flush(Node.java:523)
at com.impetus.kundera.persistence.PersistenceDelegator.flush(PersistenceDelegator.java:413)
at com.impetus.kundera.persistence.PersistenceDelegator.persist(PersistenceDelegator.java:151)
at com.impetus.kundera.persistence.EntityManagerImpl.persist(EntityManagerImpl.java:168)

@mevivs
Copy link
Collaborator

mevivs commented Sep 17, 2013

Hi,
I mean did you try to execute CQL3 query for same scenario via cqlsh?

-Vivek

@jfgosselin
Copy link
Author

Yes , with cqlsh : INSERT INTO test(id,data) VALUES('123',0x6120626c6f62);

But Kundera is doing a .toString()

@ghost ghost assigned chhavigangwal Sep 18, 2013
chhavigangwal added a commit that referenced this issue Sep 24, 2013
@mevivs
Copy link
Collaborator

mevivs commented Sep 24, 2013

A fix has been pushed in current trunk branch. Releasing with 2.8

-Vivek

@mevivs
Copy link
Collaborator

mevivs commented Sep 25, 2013

Any update. Got a chance to verify ?

-Vivek

@jfgosselin
Copy link
Author

Thanks for the fix!

Do you have maven repo for 2.8-SNAPSHOT ?

@mevivs
Copy link
Collaborator

mevivs commented Sep 25, 2013

Nope. you need to build

@jfgosselin
Copy link
Author

Problem solved ! Thanks

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

3 participants