You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
Copy file name to clipboardExpand all lines: src/main/antora/modules/ROOT/pages/cassandra.adoc
+73Lines changed: 73 additions & 0 deletions
Display the source diff
Display the rich diff
Original file line number
Diff line number
Diff line change
@@ -2,6 +2,7 @@
2
2
= Cassandra Support
3
3
:page-section-summary-toc: 1
4
4
5
+
This part of the reference documentation explains the core functionality offered by Spring Data for Apache Cassandra.
5
6
Spring Data support for Apache Cassandra contains a wide range of features:
6
7
7
8
* Spring configuration support with xref:cassandra/configuration.adoc[Java-based `@Configuration` classes or the XML namespace].
@@ -13,5 +14,77 @@ Spring Data support for Apache Cassandra contains a wide range of features:
13
14
* Java-based xref:cassandra/template.adoc#cassandra.template.query[query, criteria, and update DSLs].
14
15
* Automatic implementation of xref:repositories.adoc[imperative and reactive `Repository` interfaces] including support for xref:repositories/custom-implementations.adoc[custom query methods].
15
16
17
+
[[cassandra.abstractions]]
18
+
== Abstractions
19
+
20
+
Spring Data for Apache Cassandra allows interaction on both the CQL and the entity level.
21
+
22
+
The value provided by the Spring Data for Apache Cassandra abstraction is perhaps best shown by the sequence of actions outlined in the table below.
23
+
The table shows which actions Spring take care of and which actions are the responsibility of you, the application developer.
24
+
25
+
[[cassandra.modules.who-does-what]]
26
+
.Spring Data for Apache Cassandra - who does what?
27
+
|===
28
+
| Action| Spring| You
29
+
30
+
| Define connection parameters.
31
+
|
32
+
| X
33
+
34
+
| Open the connection.
35
+
| X
36
+
|
37
+
38
+
| Specify the CQL statement.
39
+
|
40
+
| X
41
+
42
+
| Declare parameters and provide parameter values
43
+
|
44
+
| X
45
+
46
+
| Prepare and run the statement.
47
+
| X
48
+
|
49
+
50
+
| Set up the loop to iterate through the results (if any).
51
+
| X
52
+
|
53
+
54
+
| Do the work for each iteration.
55
+
|
56
+
| X
57
+
58
+
| Process any exception.
59
+
| X
60
+
|
61
+
62
+
| Close the Session.
63
+
| X
64
+
|
65
+
|===
66
+
67
+
The core CQL support takes care of all the low-level details that can make Cassandra and CQL such a tedious API with which to develop.
68
+
Using mapped entity objects allows schema generation, object mapping, and repository support.
69
+
70
+
[[cassandra.choose-style]]
71
+
=== Choosing an Approach for Cassandra Database Access
72
+
73
+
You can choose among several approaches to use as a basis for your Cassandra database access.
74
+
Spring's support for Apache Cassandra comes in different flavors.
75
+
Once you start using one of these approaches, you can still mix and match to include a feature from a different approach.
76
+
The following approaches work well:
77
+
78
+
* xref:cassandra/cql-template.adoc[`CqlTemplate`] and xref:cassandra/reactive-cassandra.adoc[`ReactiveCqlTemplate`] are the classic Spring CQL approach and the most popular.
79
+
This is the "`lowest-level`" approach.
80
+
Note that components like `CassandraTemplate`
81
+
use `CqlTemplate` under-the-hood.
82
+
* xref:cassandra/template.adoc[`CassandraTemplate`] wraps a `CqlTemplate` to provide query result-to-object mapping and the use of `SELECT`, `INSERT`, `UPDATE`, and `DELETE` methods instead of writing CQL statements.
83
+
This approach provides better documentation and ease of use.
84
+
* xref:cassandra/reactive-cassandra.adoc[`ReactiveCassandraTemplate`] wraps a `ReactiveCqlTemplate` to provide query result-to-object mapping and the use of `SELECT`, `INSERT`, `UPDATE`, and `DELETE` methods instead of writing CQL statements.
85
+
This approach provides better documentation and ease of use.
86
+
* Repository Abstraction lets you create repository declarations in your data access layer.
87
+
The goal of Spring Data's repository abstraction is to significantly reduce the amount of boilerplate code required to implement data access layers for various persistence stores.
88
+
16
89
For most data-oriented tasks, you can use the `[Reactive|Async]CassandraTemplate` or the `Repository` support, both of which use the rich object-mapping functionality. `[Reactive|Async]CqlTemplate` is commonly used to increment counters or perform ad-hoc CRUD operations. `[Reactive|Async]CqlTemplate` also provides callback methods that make it easy to get low-level API objects, such as `com.datastax.oss.driver.api.core.CqlSession`, which lets you communicate directly with Cassandra.
17
90
Spring Data for Apache Cassandra uses consistent naming conventions on objects in various APIs to those found in the DataStax Java Driver so that they are familiar and so that you can map your existing knowledge onto the Spring APIs.
0 commit comments