SlideShare a Scribd company logo
CASSANDRA
INTEGRATION
Spring Data
CASSANDRA INTRO
SPRING DATA
CASSANDRA
Rationale
• Reduces ramp up time and code required to work with
Cassandra
• Clear, annotation based mappings for java objects to
Cassandra tables
• Good fit if already using spring data / spring boot
• Minimal property based configuration
Features
• Uses common spring data repository pattern
• Synchronous and Asynchronous requests via the
DataStax Java Driver
• XML based CQL schema creation
• JavaConfig / XML support via properties
• QueryBuilder interface for complex query creation.
Annotated POJOs
• Allows easy mapping of annotated POJOs to Cassandra
tables.
@Table("users")
public class User {
@PrimaryKey("user_id")
private String userId;
@Column("first_name")
private String firstName;
@Column("last_name")
private String lastName;
private String password;
Spring Repository Support
• Basic Support of Spring Data Repository pattern.
• Provides CRUD operations without code, findOne, findAll,
save (upsert), delete.
• Easily extensible with custom queries.
public interface UserRepository extends CassandraRepository<User> {
@Query("select * from users where user_id = ?0")
User findByUserId(String userId);
}
Primary Keys
• Easily define simple, compound or composite primary
keys. Allows for narrow or wide rows.
• Simple Key example:
@PrimaryKey("user_id")
private String userId;
• Compound Key with Cluster Column Example:
@PrimaryKeyColumn(name = "eid", ordinal = 0, type = PrimaryKeyType.PARTITIONED)
private Integer eid;
@PrimaryKeyColumn(name = "day", ordinal = 1, type = PrimaryKeyType.PARTITIONED)
private Integer day;
@PrimaryKeyColumn(name = "event_id", ordinal = 2, type = PrimaryKeyType.CLUSTERED)
private UUID eventId;
Query Support
• No support for spring data “findBy” style queries at
present, e.g. findByNameLikeOrderBy
• Use @Query annotation for custom queries
@Query("select * from events_by_tag where eid = ?0 and tag = ?1")
List<Event> findByEidAndTag(Integer eid, String tag);
Query Support
• Use static BasicMapId.id() to construct primary key based
queries.
MapId id = id()
.with("eid", 1)
.with("day", 12345)
.with("eventId”, “XXXX-XXXX-XXXX”);
return eventsByDayRepository.findOne(id);
Or use Java Driver QueryBuilder
• Use QueryBuilder to create queries including batch and
transaction based queries.
Select select = QueryBuilder
.select()
.all()
.from(“events_by_day”)
.where(eq("eid", 1))
.and(eq("day", 12345))
.and(eq("eventId", “XXXX-XXXX-XXXX”));
return cassandraOperations
.select (select, Event.class);
DEMO

More Related Content

PDF
PPTX
Cloud architectural patterns and Microsoft Azure tools
PPTX
U-SQL Federated Distributed Queries (SQLBits 2016)
PPTX
Become an Expert in SQL Server with Cloud
PPTX
Survey of the Microsoft Azure Data Landscape
PPTX
Azure DocumentDB 101
PDF
MySQL Query Optimization (Basics)
PDF
Disney+ Hotstar: Scaling NoSQL for Millions of Video On-Demand Users
Cloud architectural patterns and Microsoft Azure tools
U-SQL Federated Distributed Queries (SQLBits 2016)
Become an Expert in SQL Server with Cloud
Survey of the Microsoft Azure Data Landscape
Azure DocumentDB 101
MySQL Query Optimization (Basics)
Disney+ Hotstar: Scaling NoSQL for Millions of Video On-Demand Users

What's hot (20)

PPTX
Tech-Spark: Azure SQL Databases
PPTX
Scylla Summit 2018: Adventures in AdTech: Processing 50 Billion User Profiles...
PPTX
3 CityNetConf - sql+c#=u-sql
PDF
In Memory Data Pipeline And Warehouse At Scale - BerlinBuzzwords 2015
PDF
Basic Introduction to Crate @ ViennaDB Meetup
PPTX
Oracle Query Optimizer - An Introduction
ODP
Elastic Stack ELK, Beats, and Cloud
PPT
MySQL HA Percona cluster @ MySQL meetup Mumbai
PDF
Elasticsearch in Production (London version)
PPTX
Apache Cassandra Lunch #71: Creating a User Profile Using DataStax Astra and ...
PDF
The SparkSQL things you maybe confuse
PDF
Introduction to elasticsearch
PPTX
Vitalii Bondarenko "Machine Learning on Fast Data"
PDF
Gab document db scaling database
PPTX
Microsoft's Hadoop Story
PPTX
R in Power BI
PDF
Introduction to elasticsearch
PDF
Elasticsearch in production Boston Meetup October 2014
PPTX
Using Couchbase and Elasticsearch as data layers
PDF
20141206 4 q14_dataconference_i_am_your_db
Tech-Spark: Azure SQL Databases
Scylla Summit 2018: Adventures in AdTech: Processing 50 Billion User Profiles...
3 CityNetConf - sql+c#=u-sql
In Memory Data Pipeline And Warehouse At Scale - BerlinBuzzwords 2015
Basic Introduction to Crate @ ViennaDB Meetup
Oracle Query Optimizer - An Introduction
Elastic Stack ELK, Beats, and Cloud
MySQL HA Percona cluster @ MySQL meetup Mumbai
Elasticsearch in Production (London version)
Apache Cassandra Lunch #71: Creating a User Profile Using DataStax Astra and ...
The SparkSQL things you maybe confuse
Introduction to elasticsearch
Vitalii Bondarenko "Machine Learning on Fast Data"
Gab document db scaling database
Microsoft's Hadoop Story
R in Power BI
Introduction to elasticsearch
Elasticsearch in production Boston Meetup October 2014
Using Couchbase and Elasticsearch as data layers
20141206 4 q14_dataconference_i_am_your_db
Ad

Viewers also liked (14)

PPTX
Cassandra Applications Benchmarking
PDF
Apache Cassandra For Java Developers - Why, What and How. LJC @ UCL October 2014
PPTX
온톨로지 개론
PPTX
How companies use NoSQL and Couchbase
PPT
Introduction to RDF
PDF
RDF 해설서
PPT
온톨로지 & 규칙 추론 시스템
PPT
온톨로지 추론 개요
PPTX
온톨로지 개념 및 표현언어
PPTX
RDF 개념 및 구문 소개
PPT
RDF and OWL
PDF
Cassandra By Example: Data Modelling with CQL3
PDF
Collaborative Filtering with Spark
ODP
Web 3.0 The Semantic Web
Cassandra Applications Benchmarking
Apache Cassandra For Java Developers - Why, What and How. LJC @ UCL October 2014
온톨로지 개론
How companies use NoSQL and Couchbase
Introduction to RDF
RDF 해설서
온톨로지 & 규칙 추론 시스템
온톨로지 추론 개요
온톨로지 개념 및 표현언어
RDF 개념 및 구문 소개
RDF and OWL
Cassandra By Example: Data Modelling with CQL3
Collaborative Filtering with Spark
Web 3.0 The Semantic Web
Ad

Similar to Spring Data Cassandra (20)

PPTX
Cassandra Overview
KEY
Cassandra integrations
PDF
Lambda Architecture with Spark, Spark Streaming, Kafka, Cassandra, Akka and S...
PPTX
cassandra_presentation_final
PPTX
Cassandra
PPTX
Appache Cassandra
PDF
Analytics with Cassandra & Spark
PPTX
Spark sql
PDF
Elassandra: Elasticsearch as a Cassandra Secondary Index (Rémi Trouville, Vin...
PDF
Using cassandra as a distributed logging to store pb data
PPTX
Spark + Cassandra = Real Time Analytics on Operational Data
PPTX
5 Ways to Use Spark to Enrich your Cassandra Environment
PPTX
CASSANDRA apache cassandra apacheee.pptx
PPTX
Cassandra Java APIs Old and New – A Comparison
PPTX
Introduction to NoSQL CassandraDB
PPTX
Scala and Spark are Ideal for Big Data
PDF
Lightning fast analytics with Spark and Cassandra
PDF
Cassandra & Spark for IoT
PPTX
Jump Start with Apache Spark 2.0 on Databricks
PPTX
Apache Cassandra introduction
Cassandra Overview
Cassandra integrations
Lambda Architecture with Spark, Spark Streaming, Kafka, Cassandra, Akka and S...
cassandra_presentation_final
Cassandra
Appache Cassandra
Analytics with Cassandra & Spark
Spark sql
Elassandra: Elasticsearch as a Cassandra Secondary Index (Rémi Trouville, Vin...
Using cassandra as a distributed logging to store pb data
Spark + Cassandra = Real Time Analytics on Operational Data
5 Ways to Use Spark to Enrich your Cassandra Environment
CASSANDRA apache cassandra apacheee.pptx
Cassandra Java APIs Old and New – A Comparison
Introduction to NoSQL CassandraDB
Scala and Spark are Ideal for Big Data
Lightning fast analytics with Spark and Cassandra
Cassandra & Spark for IoT
Jump Start with Apache Spark 2.0 on Databricks
Apache Cassandra introduction

Recently uploaded (20)

PDF
MIND Revenue Release Quarter 2 2025 Press Release
PPTX
Big Data Technologies - Introduction.pptx
PDF
Unlocking AI with Model Context Protocol (MCP)
PDF
Empathic Computing: Creating Shared Understanding
PDF
7 ChatGPT Prompts to Help You Define Your Ideal Customer Profile.pdf
PDF
Spectral efficient network and resource selection model in 5G networks
PPTX
MYSQL Presentation for SQL database connectivity
PPT
Teaching material agriculture food technology
PPTX
Spectroscopy.pptx food analysis technology
PDF
Peak of Data & AI Encore- AI for Metadata and Smarter Workflows
PDF
Agricultural_Statistics_at_a_Glance_2022_0.pdf
DOCX
The AUB Centre for AI in Media Proposal.docx
PPTX
A Presentation on Artificial Intelligence
PPTX
KOM of Painting work and Equipment Insulation REV00 update 25-dec.pptx
PDF
gpt5_lecture_notes_comprehensive_20250812015547.pdf
PDF
Network Security Unit 5.pdf for BCA BBA.
PPTX
Programs and apps: productivity, graphics, security and other tools
PDF
Advanced methodologies resolving dimensionality complications for autism neur...
PDF
Blue Purple Modern Animated Computer Science Presentation.pdf.pdf
PDF
Electronic commerce courselecture one. Pdf
MIND Revenue Release Quarter 2 2025 Press Release
Big Data Technologies - Introduction.pptx
Unlocking AI with Model Context Protocol (MCP)
Empathic Computing: Creating Shared Understanding
7 ChatGPT Prompts to Help You Define Your Ideal Customer Profile.pdf
Spectral efficient network and resource selection model in 5G networks
MYSQL Presentation for SQL database connectivity
Teaching material agriculture food technology
Spectroscopy.pptx food analysis technology
Peak of Data & AI Encore- AI for Metadata and Smarter Workflows
Agricultural_Statistics_at_a_Glance_2022_0.pdf
The AUB Centre for AI in Media Proposal.docx
A Presentation on Artificial Intelligence
KOM of Painting work and Equipment Insulation REV00 update 25-dec.pptx
gpt5_lecture_notes_comprehensive_20250812015547.pdf
Network Security Unit 5.pdf for BCA BBA.
Programs and apps: productivity, graphics, security and other tools
Advanced methodologies resolving dimensionality complications for autism neur...
Blue Purple Modern Animated Computer Science Presentation.pdf.pdf
Electronic commerce courselecture one. Pdf

Spring Data Cassandra

  • 4. Rationale • Reduces ramp up time and code required to work with Cassandra • Clear, annotation based mappings for java objects to Cassandra tables • Good fit if already using spring data / spring boot • Minimal property based configuration
  • 5. Features • Uses common spring data repository pattern • Synchronous and Asynchronous requests via the DataStax Java Driver • XML based CQL schema creation • JavaConfig / XML support via properties • QueryBuilder interface for complex query creation.
  • 6. Annotated POJOs • Allows easy mapping of annotated POJOs to Cassandra tables. @Table("users") public class User { @PrimaryKey("user_id") private String userId; @Column("first_name") private String firstName; @Column("last_name") private String lastName; private String password;
  • 7. Spring Repository Support • Basic Support of Spring Data Repository pattern. • Provides CRUD operations without code, findOne, findAll, save (upsert), delete. • Easily extensible with custom queries. public interface UserRepository extends CassandraRepository<User> { @Query("select * from users where user_id = ?0") User findByUserId(String userId); }
  • 8. Primary Keys • Easily define simple, compound or composite primary keys. Allows for narrow or wide rows. • Simple Key example: @PrimaryKey("user_id") private String userId; • Compound Key with Cluster Column Example: @PrimaryKeyColumn(name = "eid", ordinal = 0, type = PrimaryKeyType.PARTITIONED) private Integer eid; @PrimaryKeyColumn(name = "day", ordinal = 1, type = PrimaryKeyType.PARTITIONED) private Integer day; @PrimaryKeyColumn(name = "event_id", ordinal = 2, type = PrimaryKeyType.CLUSTERED) private UUID eventId;
  • 9. Query Support • No support for spring data “findBy” style queries at present, e.g. findByNameLikeOrderBy • Use @Query annotation for custom queries @Query("select * from events_by_tag where eid = ?0 and tag = ?1") List<Event> findByEidAndTag(Integer eid, String tag);
  • 10. Query Support • Use static BasicMapId.id() to construct primary key based queries. MapId id = id() .with("eid", 1) .with("day", 12345) .with("eventId”, “XXXX-XXXX-XXXX”); return eventsByDayRepository.findOne(id);
  • 11. Or use Java Driver QueryBuilder • Use QueryBuilder to create queries including batch and transaction based queries. Select select = QueryBuilder .select() .all() .from(“events_by_day”) .where(eq("eid", 1)) .and(eq("day", 12345)) .and(eq("eventId", “XXXX-XXXX-XXXX”)); return cassandraOperations .select (select, Event.class);
  • 12. DEMO