0

We using Kundera ORM for connecting to Cassandra from REST service. In the persistence.xml we are specifying client lookup class as ThriftClientFactory as below

<property name="kundera.client.lookup.class"
                value="com.impetus.client.cassandra.thrift.ThriftClientFactory" />

Is this the right way to connect to cassandra or is there any way we can connect to Cassandra using CQL through Kundera?

Raj
  • 115
  • 8

1 Answers1

0

Yes, Kundera's ThriftClient uses CQL for communicating with Cassandra. Also, make sure you are enabling CQL3 from your application while using this client.

Setting CQL3: You can choose any method given below

  • In EntityManagerFactory

    HashMap propertyMap = new HashMap();
    propertyMap.put(CassandraConstants.CQL_VERSION, CassandraConstants.CQL_VERSION_3_0);
    EntityManagerFactory emf = Persistence.createEntityManagerFactory("cassandra_pu", propertyMap);
    
  • In EntityManager

    EntityManagerFactory emf = Persistence.createEntityManagerFactory("cassandra_pu");
    EntityManager em = emf.createEntityManager();
    em.setProperty("cql.version", "3.0.0");
    
karthik manchala
  • 13,492
  • 1
  • 31
  • 55
  • Thanks Karthik for your response. Currently I am using com.impetus.client.cassandra.thrift.ThriftClientFactory class as "kundera.client.lookup.class" and its connecting through thrift prot which is 9160. But in our cassandra prod cluster 9160 port is disabled and got instruction to use CQL3 port which is 9042. So which class should I use for kundera client look up? Is it advisible to use "com.impetus.kundera.client.cassandra.dsdriver.DSClientFactory"? – Raj Mar 10 '17 at 18:10
  • @Raj Yes, you can use `DSClientFactory` but auto schema generation feature wouldn't work in this case. If thats not a requirement, then you can proceed with `com.impetus.kundera.client.cassandra.dsdriver.DSClientFacto‌​ry` – karthik manchala Mar 11 '17 at 09:18