Search code examples
kundera

Regarding Kundera and Cassandra ThriftClient


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?


Solution

  • 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");