Search code examples
spring-bootcassandradatastax-java-driver

Session vs CqlSession in CassandraTemplate compatibility in Cassandra Java driver


I'm trying to migrate a SpringBoot project from spring-data-cassandra 2.1.x to 3.2.x and I encountered an issue:

In 2.1.x version CassandraTemplate is created as follows new CassandraTemplate(getCassandraSession()), where getCassandraSession() returns com.datastax.driver.core.Session.

But in 3.2.x version CassandraTemplate doesn't have such a constructor. It only supports com.datastax.oss.driver.api.core.CqlSession. Is there a way to retrieve CqlSession from Session or to make it backward compatible?

Datastax version is 3.6.0. Thank you!


Solution

  • Datastax upgraded its driver in January 2019 from 3.x to 4.x with no backward compatibility. Spring Data 3.x moved the latest version of the drivers a while ago indeed.

    Solution is to upgrade your code to an updated version or stay stuck with Spring Data Cassandra 2.x (and Spring Boot 1.x).

    To migrate your code from 3x to 4x please follow the upgrade guide and some code to help you.