(Quick Reference)

5 Cassandra Low-level API - Reference Documentation

Authors: Paras Lakhani

Version: 5.0.8.RELEASE

5 Cassandra Low-level API

A lower level API is provided by the plugin that is based on the Spring Data Cassandra project.

Spring Data Cassandra provides a CassandraTemplate with methods to execute statements using the regular Cassandra Java Driver

To get hold of the cassandraTemplate instance inside a controller or service simply define a cassandraTemplate property. An example can be seen below:

def cassandraTemplate

def myAction = { def people = [] people << new Person(firstName: "Fred", lastName: "Flintstone") people << new Person(firstName: "Barney", lastName: "Rubble") cassandraTemplate.insert(people) }

You can also create a CQL or Java Driver statement and execute it using cassandraTemplate

Select personSelect = QueryBuilder.select().all().from("person")
List personList = cassandraTemplate.select(personSelect, Person.class)

String personCQL = "SELECT firstName FROM person" List personList = cassandraTemplate.select(personCQL, Person.class)