CREATE TABLE Cats (
block_id uuid,
breed text,
color text,
short_hair boolean,
PRIMARY KEY ((block_id, breed), color, short_hair)
);Hi Chhavi,
Thanks for the reply.
I tried running the
sample examples as referred by you but was not able to create the table
as expected. I am using cassandra 2.1.3 and kundera version 2.15.
Here is what I see :-
- The table structure doesn't get created with expected multiple partitions.
- The table gets created with partitionKey as "blob".
- As the table is not created with proper structure the data insertion fails.
Please find the snapshots of the classes I am using from your example below. Also find the snapshot of table structure created.
Here is log trace from eclipse which fails on insertion as I mentioned above.
2015-04-06 21:16:21,772 INFO main com.impetus.kundera.persistence.EntityManagerFactoryImpl - EntityManagerFactory created for persistence unit : oneplatform_pu
2015-04-06 21:16:21,775 DEBUG main com.impetus.kundera.persistence.EntityManagerImpl - Creating EntityManager for persistence unit : oneplatform_pu
2015-04-06 21:16:21,781 INFO main com.impetus.kundera.persistence.EntityManagerImpl - Returning client instance for persistence unit oneplatform_pu.
2015-04-06 21:16:21,781 DEBUG main com.impetus.kundera.loader.GenericClientFactory - Returning fresh client instance for persistence unit : oneplatform_pu
2015-04-06 21:16:21,792 DEBUG main com.impetus.kundera.persistence.EntityManagerImpl - Created EntityManager for persistence unit : oneplatform_pu
2015-04-06 21:16:21,801 DEBUG main com.impetus.kundera.persistence.PersistenceDelegator - Flushing following flush stack to database(s) (showing stack objects from top to bottom):
[[com.thomson.citation.entity.EntityWithMultiplePartitionKey$com.thomson.citation.entity.IdWithMultiplePartitionKey@1033576a]com.thomson.citation.entity.EntityWithMultiplePartitionKey$com.thomson.citation.entity.IdWithMultiplePartitionKey@1033576a]
2015-04-06 21:16:21,802 DEBUG main com.impetus.kundera.persistence.PersistenceDelegator - Data persisted successfully for entity class com.thomson.citation.entity.EntityWithMultiplePartitionKey.
2015-04-06 21:16:21,802 DEBUG main com.impetus.kundera.persistence.PersistenceDelegator - Flushing following flush stack to database(s) (showing stack objects from top to bottom):
[]
2015-04-06 21:16:21,804 INFO main com.impetus.client.cassandra.CassandraClientBase - Returning cql query INSERT INTO "entitywithmultiplepartitionkey"("entityDiscription","action","partitionKey1","partitionKey2","clusterkey1","clusterkey2") VALUES('Entity to test composite key with multiple partition key.','Persisting','partitionKey1',1,'clusterkey1',11) .
2015-04-06 21:16:21,805 ERROR main com.impetus.client.cassandra.CassandraClientBase - Error while executing query BEGIN BATCH INSERT INTO "entitywithmultiplepartitionkey"("entityDiscription","action","partitionKey1","partitionKey2","clusterkey1","clusterkey2") VALUES('Entity to test composite key with multiple partition key.','Persisting','partitionKey1',1,'clusterkey1',11) APPLY BATCH
2015-04-06 21:16:21,805 ERROR main com.impetus.client.cassandra.CassandraClientBase - Error during executing query BEGIN BATCH INSERT INTO "entitywithmultiplepartitionkey"("entityDiscription","action","partitionKey1","partitionKey2","clusterkey1","clusterkey2") VALUES('Entity to test composite key with multiple partition key.','Persisting','partitionKey1',1,'clusterkey1',11) APPLY BATCH, Caused by: com.impetus.kundera.KunderaException: InvalidRequestException(why:Unknown identifier partitionKey1) .
2015-04-06 21:16:21,805 ERROR main com.impetus.client.cassandra.CassandraClientBase - Error while persisting record. Caused by: .
javax.persistence.PersistenceException: com.impetus.kundera.KunderaException: InvalidRequestException(why:Unknown identifier partitionKey1)
at com.impetus.client.cassandra.CassandraClientBase.executeCQLQuery(CassandraClientBase.java:1719)
at com.impetus.client.cassandra.CassandraClientBase.executeBatch(CassandraClientBase.java:1447)
at com.impetus.kundera.persistence.PersistenceDelegator.execute(PersistenceDelegator.java:822)
at com.impetus.kundera.persistence.PersistenceDelegator.doFlush(PersistenceDelegator.java:737)
at com.impetus.kundera.persistence.PersistenceDelegator.close(PersistenceDelegator.java:571)
at com.impetus.kundera.persistence.EntityManagerImpl.close(EntityManagerImpl.java:351)
at com.thomson.dao.impl.CitationsDaoImpl.createMultiple(CitationsDaoImpl.java:696)
at com.thomson.dao.impl.CitationDaoImplTest.test52CreateMultiplePartition(CitationDaoImplTest.java:256)
at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method)
at sun.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:62)
at sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:43)
at java.lang.reflect.Method.invoke(Method.java:483)
at org.junit.runners.model.FrameworkMethod$1.runReflectiveCall(FrameworkMethod.java:50)
at org.junit.internal.runners.model.ReflectiveCallable.run(ReflectiveCallable.java:12)
at org.junit.runners.model.FrameworkMethod.invokeExplosively(FrameworkMethod.java:47)
at org.junit.internal.runners.statements.InvokeMethod.evaluate(InvokeMethod.java:17)
at org.junit.runners.ParentRunner.runLeaf(ParentRunner.java:325)
at org.junit.runners.BlockJUnit4ClassRunner.runChild(BlockJUnit4ClassRunner.java:78)
at org.junit.runners.BlockJUnit4ClassRunner.runChild(BlockJUnit4ClassRunner.java:57)
at org.junit.runners.ParentRunner$3.run(ParentRunner.java:290)
at org.junit.runners.ParentRunner$1.schedule(ParentRunner.java:71)
at org.junit.runners.ParentRunner.runChildren(ParentRunner.java:288)
at org.junit.runners.ParentRunner.access$000(ParentRunner.java:58)
at org.junit.runners.ParentRunner$2.evaluate(ParentRunner.java:268)
at org.junit.internal.runners.statements.RunBefores.evaluate(RunBefores.java:26)
at org.junit.internal.runners.statements.RunAfters.evaluate(RunAfters.java:27)
at org.junit.runners.ParentRunner.run(ParentRunner.java:363)
at org.eclipse.jdt.internal.junit4.runner.JUnit4TestReference.run(JUnit4TestReference.java:50)
at org.eclipse.jdt.internal.junit.runner.TestExecution.run(TestExecution.java:38)
at org.eclipse.jdt.internal.junit.runner.RemoteTestRunner.runTests(RemoteTestRunner.java:459)
at org.eclipse.jdt.internal.junit.runner.RemoteTestRunner.runTests(RemoteTestRunner.java:675)
at org.eclipse.jdt.internal.junit.runner.RemoteTestRunner.run(RemoteTestRunner.java:382)
at org.eclipse.jdt.internal.junit.runner.RemoteTestRunner.main(RemoteTestRunner.java:192)
Caused by: com.impetus.kundera.KunderaException: InvalidRequestException(why:Unknown identifier partitionKey1)
at com.impetus.client.cassandra.CassandraClientBase.execute(CassandraClientBase.java:2101)
at com.impetus.client.cassandra.CassandraClientBase.executeCQLQuery(CassandraClientBase.java:1708)
... 32 more
Caused by: InvalidRequestException(why:Unknown identifier partitionKey1)
at org.apache.cassandra.thrift.Cassandra$execute_cql3_query_result$execute_cql3_query_resultStandardScheme.read(Cassandra.java:49032)
at org.apache.cassandra.thrift.Cassandra$execute_cql3_query_result$execute_cql3_query_resultStandardScheme.read(Cassandra.java:49009)
at org.apache.cassandra.thrift.Cassandra$execute_cql3_query_result.read(Cassandra.java:48924)
at org.apache.thrift.TServiceClient.receiveBase(TServiceClient.java:78)
at org.apache.cassandra.thrift.Cassandra$Client.recv_execute_cql3_query(Cassandra.java:1693)
at org.apache.cassandra.thrift.Cassandra$Client.execute_cql3_query(Cassandra.java:1678)
at com.impetus.client.cassandra.CassandraClientBase.execute(CassandraClientBase.java:2097)
... 33 more
Please suggest.
Thanks,
TK
Map<String, Object> puProperties = new HashMap<String, Object>();
puProperties.put(CassandraConstants.CQL_VERSION, CassandraConstants.CQL_VERSION_3_0);
EntityManagerFactory emf = Persistence.createEntityManagerFactory("cassandra_pu", puProperties);
EntityManager em = emf.createEntityManager();