liveBook · Manning

Primary key

As explained in Spring in Action, Sixth Edition

A primary key is a Cassandra key definition that identifies rows and can combine partitioning and clustering components.

A primary key identifies rows in Cassandra. It may be a single key or combine a partition key, which selects the partition, with a clustering key, which orders rows within that partition. section 4.1.3

Spring Data Cassandra expresses these responsibilities through annotations:

  • @PrimaryKey marks a primary-key property, as with an ingredient identifier. section 4.1.3
  • @PrimaryKeyColumn(type=PrimaryKeyType.PARTITIONED) marks a property as the partition key. section 4.1.3
  • @PrimaryKeyColumn(type=PrimaryKeyType.CLUSTERED) marks a property as a clustering key; descending ordering places newer rows first. section 4.1.3

Taco persistence

A Taco uses a time-based UUID as its partition key and createdAt as a descending clustering key, so each partition presents newer tacos first. section 4.1.3

How Spring in Action, Sixth Edition covers it

How deep it goes
Explains key annotations, partition placement, clustering order, and generated UUIDs through a Taco mapping.
Examples
Uses Ingredient and Taco mappings, including a UUID partition key, descending createdAt clustering key, and cqlsh output.
What you can do after
Configure Cassandra domain mappings with @PrimaryKey, @PrimaryKeyColumn, partitioning, clustering order, and UUID identifiers.
How it connects
Connects primary keys with Cassandra partitions, clustering keys, UUIDs, and Spring Data Cassandra annotations.

Also explained in

Compare how 21 books explain primary key →

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.