liveBook · Manning

Cassandra

As explained in Spring in Action, Sixth Edition

Cassandra is a distributed database designed to store and query data in a wide-column data model.

Cassandra is a distributed, high-performance NoSQL database that stores rows in partitioned tables across multiple nodes. Replication can eliminate a single point of failure, while its eventually consistent model differs from relational databases. section 4.1

A Spring application can connect to Cassandra with a short setup sequence:

  • Replace relational persistence dependencies with the nonreactive Spring Data Cassandra starter. section 4.1.1
  • Start a Cassandra cluster, including a single-node Docker cluster for development. section 4.1.1
  • Create a keyspace, the Cassandra grouping that contains tables, then configure its name and local datacenter. section 4.1.1
  • Configure contact points, port, username, and password when connecting to a deployed cluster. section 4.1.1

Repository integration

Spring Data Cassandra repositories follow the familiar Spring Data pattern: declare an interface extending CrudRepository. An IngredientRepository can use String as its primary-key type, while an OrderRepository can use UUID. The repository is then ready to persist the corresponding domain objects with little implementation code. section 4.1.4

<dependency>
  <groupId>org.springframework.boot</groupId>
  <artifactId>spring-boot-starter-data-cassandra</artifactId>
</dependency>

Inspect the Spring Boot dependency that activates Spring Data Cassandra and its repository autoconfiguration. section 4.1.1

How Spring in Action, Sixth Edition covers it

How deep it goes
Explains distribution, replication, setup, keyspaces, configuration, and repositories, while deferring Cassandra internals to its documentation.
Examples
Demonstrates Docker clusters, CQL keyspace creation, YAML configuration, and IngredientRepository and OrderRepository interfaces.
What it assumes
Assumes familiarity with Spring Data repositories and domain objects while introducing Cassandra concepts and configuration.
What you can do after
Build Cassandra persistence by configuring Spring Data, creating a keyspace, and declaring CrudRepository interfaces.
How it connects
Connects Cassandra with NoSQL databases, Spring Data, repositories, keyspaces, distributed systems, and relational database alternatives.

Related concepts

This explainer was generated by Manning's knowledge graph from the text of Spring in Action, Sixth Edition. The section links point to the parts of the book it draws on.