diff --git a/src/docbkx/reference/cassandra.xml b/src/docbkx/reference/cassandra.xml
index 0d1e1749e..053bcc56c 100644
--- a/src/docbkx/reference/cassandra.xml
+++ b/src/docbkx/reference/cassandra.xml
@@ -247,7 +247,7 @@ public class CassandraApp {
cassandra.contactpoints=10.1.55.80,10.1.55.81
cassandra.port=9042
cassandra.keyspace=showcaseWe will use spring to load these
- properties into the Spring Context in the next two examples.
+ properties into the Spring Context in the next two examples.
@@ -269,32 +269,38 @@ cassandra.keyspace=showcaseWe will use spring to load these
<?xml version='1.0'?>
<beans xmlns="http://www.springframework.org/schema/beans"
- xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xmlns:cassandra="http://www.springframework.org/schema/data/cassandra"
- xmlns:context="http://www.springframework.org/schema/context"
- xsi:schemaLocation="http://www.springframework.org/schema/cql http://www.springframework.org/schema/cql/spring-cql-1.0.xsd
- http://www.springframework.org/schema/data/cassandra http://www.springframework.org/schema/data/cassandra/spring-cassandra-1.0.xsd
- http://www.springframework.org/schema/beans http://www.springframework.org/schema/beans/spring-beans.xsd
- http://www.springframework.org/schema/context http://www.springframework.org/schema/context/spring-context-3.2.xsd">
+ xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xmlns:cassandra="http://www.springframework.org/schema/data/cassandra"
+ xmlns:context="http://www.springframework.org/schema/context"
+ xsi:schemaLocation="http://www.springframework.org/schema/cql http://www.springframework.org/schema/cql/spring-cql-1.0.xsd
+ http://www.springframework.org/schema/data/cassandra http://www.springframework.org/schema/data/cassandra/spring-cassandra-1.0.xsd
+ http://www.springframework.org/schema/beans http://www.springframework.org/schema/beans/spring-beans.xsd
+ http://www.springframework.org/schema/context http://www.springframework.org/schema/context/spring-context-3.2.xsd">
+ <!-- Loads the properties into the Spring Context and uses them to fill
+ in placeholders in the bean definitions -->
+ <context:property-placeholder location="classpath:cassandra.properties" />
- <!-- Loads the properties into the Spring Context and uses them to fill
- in placeholders in the bean definitions -->
- <context:property-placeholder location="classpath:cassandra.properties" />
+ <!-- REQUIRED: The Cassandra Cluster -->
+ <cassandra:cluster contact-points="${cassandra.contactpoints}"
+ port="${cassandra.port}" />
- <!-- REQUIRED: The Cassandra Cluster -->
- <cassandra:cluster contact-points="${cassandra.contactpoints}" port="${cassandra.port}" />
+ <!-- REQUIRED: The Cassandra Session, built from the Cluster, and attaching
+ to a keyspace -->
+ <cassandra:session keyspace-name="${cassandra.keyspace}" />
- <!-- REQUIRED: The Cassandra Session, built from the Cluster, and attaching to a keyspace -->
- <cassandra:session keyspace-name="${cassandra.keyspace}" />
+ <!-- REQUIRED: The Default Cassandra Mapping Context used by CassandraConverter -->
+ <cassandra:mapping />
- <!-- REQUIRED: The Default Cassandra Converter used by CassandraTemplate -->
- <cassandra:converter/>
+ <!-- REQUIRED: The Default Cassandra Converter used by CassandraTemplate -->
+ <cassandra:converter />
- <!-- REQUIRED: The Cassandra Template is the building block of all Spring Data Cassandra -->
- <cassandra:template/>
+ <!-- REQUIRED: The Cassandra Template is the building block of all Spring
+ Data Cassandra -->
+ <cassandra:template id="cassandraTemplate" />
- <!-- OPTIONAL: If you are using Spring Data Cassandra Repositories, add your base packages to scan here-->
- <cassandra:repositories base-package="org.spring.cassandra.example.repo" />
+ <!-- OPTIONAL: If you are using Spring Data Cassandra Repositories, add
+ your base packages to scan here -->
+ <cassandra:repositories base-package="org.spring.cassandra.example.repo" />
</beans>
@@ -319,7 +325,43 @@ cassandra.keyspace=showcaseWe will use spring to load these
Instantiating CassandraTemplate
- CassandraTemplate requires a Cassandra Session object.
+ CassandraTemplate should always be configured
+ as a Spring Bean, although we show an example above where you can
+ instantiate it directly. But for the purposes of this being a Spring
+ module, lets assume we are using the Spring Container.
+
+ CassandraTemplate is an implementation of
+ CassandraOperations. You should always assign your
+ CassandraTemplate to its interface definition,
+ CassandraOperations.
+
+ There are 2 easy ways to get a
+ CassandraTemplate, depending on how you load you
+ Spring Application Context.
+
+ AutoWiring
+
+ @Autowired
+private CassandraOperations cassandraOperations;
+
+ Like all Spring Autowiring, this assumes there is only one bean of
+ type CassandraOperations in the
+ ApplicationContext. If you have multiple
+ CassandraTemplate beans (which will be the case if
+ you are working with multiple keyspaces in the same project), use the
+ @Qualifier annotation to designate which bean you
+ want to Autowire.
+
+ @Autowired
+@Qualifier("myTemplateBeanId")
+private CassandraOperations cassandraOperations;
+
+ Bean Lookup with ApplicationContext
+
+ You can also just lookup the CassandraTemplate
+ bean from the ApplicationContext.
+
+ CassandraOperations cassandraOperations = applicationContext.getBean("cassandraTemplate", CassandraOperations.class);
@@ -337,8 +379,6 @@ cassandra.keyspace=showcaseWe will use spring to load these
Cassandra requires that you have at least 1 Partition Key field
for a CQL Table. Alternately, you can have one or more Clustering Key
fields.
-
- TODO With Examples
@@ -362,13 +402,10 @@ cassandra.keyspace=showcaseWe will use spring to load these
Upserting rows in a CQL table
- TODO With Examples
-
-
-
- Finding and Upserting rowa in a CQL table
-
- TODO With Examples
+ To upsert a row in Cassandra, use the insert logic explained in
+ the previous section. When you insert a row into Cassandra, and there is
+ already a row for that primary key value, the row is overwritten by the
+ data in the new insert.