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/cql-template.adoc
+7-6Lines changed: 7 additions & 6 deletions
Original file line number
Diff line number
Diff line change
@@ -1,21 +1,22 @@
1
1
[[cassandra.cql-template]]
2
2
= CQL Template API
3
3
4
-
The `CqlTemplate` class (and its reactive variant `ReactiveCqlTemplate`) is the central class in the core CQL package.
4
+
The javadoc:org.springframework.data.cassandra.core.cql.CqlTemplate[] class (and its reactive variant javadoc:org.springframework.data.cassandra.core.cql.ReactiveCqlTemplate[]) is the central class in the core CQL package.
5
5
It handles the creation and release of resources.
6
6
It performs the basic tasks of the core CQL workflow, such as statement creation and execution, and leaves application code to provide CQL and extract results.
7
7
The `CqlTemplate` class executes CQL queries and update statements, performs iteration over `ResultSet` instances and extraction of returned parameter values.
8
8
It also catches CQL exceptions and translates them to the generic, more informative, exception hierarchy defined in the `org.springframework.dao` package.
9
9
10
10
When you use the `CqlTemplate` for your code, you need only implement callback interfaces, which have a clearly defined contract.
11
-
Given a `Connection`, the `PreparedStatementCreator` callback interface creates a xref:cassandra/prepared-statements.adoc#cassandra.template.prepared-statements.cql[prepared statement] with the provided CQL and any necessary parameter arguments.
12
-
The `RowCallbackHandler` interface extracts values from each row of a `ResultSet`.
11
+
Given a `CqlSession`, the javadoc:org.springframework.data.cassandra.core.cql.PreparedStatementCreator[] callback interface creates a xref:cassandra/prepared-statements.adoc#cassandra.template.prepared-statements.cql[prepared statement] with the provided CQL and any necessary parameter arguments.
12
+
The javadoc:org.springframework.data.cassandra.core.cql.RowCallbackHandler[] interface extracts values from each row of a `ResultSet`.
13
13
14
-
The `CqlTemplate` can be used within a DAO implementation through direct instantiation with a `SessionFactory` reference or be configured in the Spring container and given to DAOs as a bean reference. `CqlTemplate` is a foundational building block for xref:cassandra/template.adoc[`CassandraTemplate`].
14
+
The javadoc:org.springframework.data.cassandra.core.cql.CqlTemplate[] can be used within a DAO implementation through direct instantiation with a javadoc:org.springframework.data.cassandra.SessionFactory[] reference or be configured in the Spring container and given to DAOs as a bean reference. `CqlTemplate` is a foundational building block for xref:cassandra/template.adoc[`CassandraTemplate`].
15
15
16
16
All CQL issued by this class is logged at the `DEBUG` level under the category corresponding to the fully-qualified class name of the template instance (typically `CqlTemplate`, but it may be different if you use a custom subclass of the `CqlTemplate` class).
17
17
18
-
You can control fetch size, consistency level, and retry policy defaults by configuring these parameters on the CQL API instances: `CqlTemplate`, `AsyncCqlTemplate`, and `ReactiveCqlTemplate`.
18
+
You can control fetch size, consistency level, and retry policy defaults by configuring these parameters on the CQL API instances:
19
+
javadoc:org.springframework.data.cassandra.core.cql.CqlTemplate[], javadoc:org.springframework.data.cassandra.core.cql.AsyncCqlTemplate[], and javadoc:org.springframework.data.cassandra.core.cql.ReactiveCqlTemplate[].
19
20
Defaults apply if the particular query option is not set.
20
21
21
22
NOTE: `CqlTemplate` comes in different execution model flavors.
@@ -28,7 +29,7 @@ You can use `AsyncCqlTemplate` for asynchronous execution and synchronization wi
28
29
29
30
This section provides some examples of the `CqlTemplate` class in action.
30
31
These examples are not an exhaustive list of all functionality exposed by the `CqlTemplate`.
31
-
See the https://docs.spring.io/spring-data/cassandra/docs/{version}/api/[Javadoc] for that.
32
+
See the javadoc:org.springframework.data.cassandra.core.cql.CqlTemplate[Javadoc] for that.
Copy file name to clipboardExpand all lines: src/main/antora/modules/ROOT/pages/cassandra/events.adoc
+3-3Lines changed: 3 additions & 3 deletions
Original file line number
Diff line number
Diff line change
@@ -4,10 +4,10 @@
4
4
The Cassandra mapping framework has several built-in `org.springframework.context.ApplicationEvent` events that your application can respond to by registering special beans in the `ApplicationContext`.
5
5
Being based on Spring's application context event infrastructure lets other products, such as Spring Integration, easily receive these events as they are a well known eventing mechanism in Spring-based applications.
6
6
7
-
To intercept an object before it goes into the database, you can register a subclass of `org.springframework.data.cassandra.core.mapping.event.AbstractCassandraEventListener` that overrides the `onBeforeSave(…)` method.
7
+
To intercept an object before it goes into the database, you can register a subclass of javadoc:org.springframework.data.cassandra.core.mapping.event.AbstractCassandraEventListener[] that overrides the `onBeforeSave(…)` method.
8
8
When the event is dispatched, your listener is called and passed the domain object (which is a Java entity).
9
9
Entity lifecycle events can be costly and you may notice a change in the performance profile when loading large result sets.
10
-
You can disable lifecycle events on the link:https://docs.spring.io/spring-data/cassandra/docs/{version}/api/org/springframework/data/cassandra/core/CassandraTemplate.html#setEntityLifecycleEventsEnabled(boolean)[Template API].
10
+
You can disable lifecycle events on the javadoc:org.springframework.data.cassandra.core.CassandraTemplate#setEntityLifecycleEventsEnabled(boolean)[Template API].
11
11
The following example uses the `onBeforeSave` method:
Declaring these beans in your Spring `ApplicationContext` will cause them to be invoked whenever the event is dispatched.
21
21
22
-
The `AbstractCassandraEventListener` has the following callback methods:
22
+
The javadoc:org.springframework.data.cassandra.core.mapping.event.AbstractCassandraEventListener[] has the following callback methods:
23
23
24
24
* `onBeforeSave`: Called in `CassandraTemplate.insert(…)` and `.update(…)` operations before inserting or updating a row in the database but after creating the `Statement`.
25
25
* `onAfterSave`: Called in `CassandraTemplate…insert(…)` and `.update(…)` operations after inserting or updating a row in the database.
Even in this simple example, there are a few notable things to point out:
99
99
100
-
* You can create an instance of `CassandraTemplate` (or `ReactiveCassandraTemplate` for reactive usage) with a Cassandra `CqlSession`.
100
+
* You can create an instance of javadoc:org.springframework.data.cassandra.core.CassandraTemplate[] (or javadoc:org.springframework.data.cassandra.core.ReactiveCassandraTemplate[] for reactive usage) with a Cassandra `CqlSession`.
101
101
* You must annotate your POJO as a Cassandra `@Table` entity and also annotate the `@PrimaryKey`.
102
102
Optionally, you can override these mapping names to match your Cassandra database table and column names.
103
-
* You can either use raw CQL or the DataStax `QueryBuilder` API to construct your queries.
103
+
* You can either use raw CQL or the Driver `QueryBuilder` API to construct your queries.
0 commit comments