diff --git a/src/main/asciidoc/reference/cassandra.adoc b/src/main/asciidoc/reference/cassandra.adoc index 957795d13..07fde9df8 100644 --- a/src/main/asciidoc/reference/cassandra.adoc +++ b/src/main/asciidoc/reference/cassandra.adoc @@ -814,12 +814,12 @@ include::exception-translation.adoc[] == Controlling Cassandra connections Applications connect to Apache Cassandra using `Cluster` and `Session` objects. A Cassandra `Session` keeps track of -multiple connections to the individual nodes and is designed as thread-safe and long-lived object. +multiple connections to the individual nodes and is designed to be a Thread-safe, long-lived object. Usually, it's sufficient to use a single `Session` for the whole application. -Spring obtains a Cassandra `Session` through a `SessionFactory`. `SessionFactory` is part of +Spring acquires a Cassandra `Session` through a `SessionFactory`. `SessionFactory` is part of Spring Data for Apache Cassandra and is a generalized connection factory. -It allows a container or a framework to hide connection handling and routing issues from the application code. +It allows the container or framework to hide connection handling and routing issues from the application code. Here is an example of how to configure a default `SessionFactory` in Java code: @@ -828,14 +828,16 @@ Here is an example of how to configure a default `SessionFactory` in Java code: Session session = … // get hold of a Cassandra Session CqlTemplate template = new CqlTemplate(); + template.setSessionFactory(new DefaultSessionFactory(session)); ---- -`CqlTemplate` and other Template API implementations obtain a `Session` for each operation. Sessions are not closed -after invoking the desired operation due to their long-lived nature. Resource disposal responsibility lies in the using -container or framework. +`CqlTemplate` and other Template API implementations obtain a `Session` for each operation. Due to their +long-lived nature, Sessions are not closed after invoking the desired operation. Responsibility for proper +resource disposal lies with the container or framework using the Session. -You can find various `SessionFactory` implementations within the package `org.springframework.data.cassandra.core.cql.session`. +You can find various `SessionFactory` implementations within the `org.springframework.data.cassandra.core.cql.session` +package. [[cassandra.template]] == Introduction to `CassandraTemplate`