diff --git a/src/docbkx/reference/cassandra.xml b/src/docbkx/reference/cassandra.xml
index 217a47b3a..17109ef62 100644
--- a/src/docbkx/reference/cassandra.xml
+++ b/src/docbkx/reference/cassandra.xml
@@ -726,21 +726,100 @@ cassandraOperations.execute(cql);
Updating rows in a CQL table
+ Much like inserting, there are several flavors of update from which you can
+ choose.
+ Update a record with an annotated POJO.
+ cassandraOperations.update(new Person("123123123", "Alison", 35));
+ Update a row using the QueryBuilder.Update object that is part of the DataStax Java
+ Driver.
+ Update update = QueryBuilder.update("person");
+update.setConsistencyLevel(ConsistencyLevel.ONE);
+update.with(QueryBuilder.set("age", 35));
+update.where(QueryBuilder.eq("id", "123123123"));
- TODO With Examples
+cassandraOperations.execute(update);
+ Then there is always the old fashioned way. You can write your own CQL
+ statements.
+ String cql = "update person set age = 35 where id = '123123123'";
+
+cassandraOperations.execute(cql);
Methods for removing rows
+ Much like inserting, there are several flavors of delete from which you can
+ choose.
+ Delete a record with an annotated POJO.
+ cassandraOperations.delete(new Person("123123123", null, 0));
+ Delete a row using the QueryBuilder.Delete object that is part of the DataStax Java
+ Driver.
+ Delete delete = QueryBuilder.delete().from("person");
+delete.where(QueryBuilder.eq("id", "123123123"));
- TODO With Examples
+cassandraOperations.execute(delete);
+ Then there is always the old fashioned way. You can write your own CQL
+ statements.
+ String cql = "delete from person where id = '123123123'";
+
+cassandraOperations.execute(cql);
+
+
+ Methods for truncating tables
+ Much like inserting, there are several flavors of truncate from which you can
+ choose.
+ Truncate a table using the truncate() method.
+ cassandraOperations.truncate("person");
+ Truncate a table using the QueryBuilder.Truncate object that is part of the DataStax
+ Java Driver.
+ Truncate truncate = QueryBuilder.truncate("person");
+
+cassandraOperations.execute(truncate);
+ Then there is always the old fashioned way. You can write your own CQL
+ statements.
+ String cql = "truncate person";
+
+cassandraOperations.execute(cql);
Querying CQL Tables
+ Tthere are several flavors of select and query from which you can choose. Please see the
+ CassandraTemplate API documentation for all overloads available.
+ Query a table for multiple rows and map the results to a POJO.
+ String cqlAll = "select * from person";
- TODO With Examples
+List<Person> results = cassandraOperations.select(cqlAll, Person.class);
+for (Person p : results) {
+ LOG.info(String.format("Found People with Name [%s] for id [%s]", p.getName(), p.getId()));
+}
+ Query a table for a single row and map the result to a POJO.
+ String cqlOne = "select * from person where id = '123123123'";
+
+Person p = cassandraOperations.selectOne(cqlOne, Person.class);
+LOG.info(String.format("Found Person with Name [%s] for id [%s]", p.getName(), p.getId()));
+ Query a table using the QueryBuilder.Select object that is part of the DataStax Java
+ Driver.
+ Select select = QueryBuilder.select().from("person");
+select.where(QueryBuilder.eq("id", "123123123"));
+
+Person p = cassandraOperations.selectOne(select, Person.class);
+LOG.info(String.format("Found Person with Name [%s] for id [%s]", p.getName(), p.getId()));
+ Then there is always the old fashioned way. You can write your own CQL statements, and
+ there are several callback handlers for mapping the results. The example uses the RowMapper
+ interface.
+ String cqlAll = "select * from person";
+List<Person> results = cassandraOperations.query(cqlAll, new RowMapper<Person>() {
+
+ public Person mapRow(Row row, int rowNum) throws DriverException {
+ Person p = new Person(row.getString("id"), row.getString("name"), row.getInt("age"));
+ return p;
+ }
+});
+
+for (Person p : results) {
+ LOG.info(String.format("Found People with Name [%s] for id [%s]", p.getName(), p.getId()));
+}
@@ -770,25 +849,25 @@ cassandraOperations.execute(cql);
Saving using a registered Spring Converter
- TODO With Examples
+ Coming Soon!
Reading using a Spring Converter
- TODO With Examples
+ Coming Soon!
Registering Spring Converters with the CassandraConverter
- TODO With Examples
+ Coming Soon!
Converter disambiguation
- TODO With Examples
+ Coming Soon!
@@ -798,8 +877,26 @@ cassandraOperations.execute(cql);
Methods for executing commands
- The CassandraTemplate has many overrides for execute() and executeAsync(). Pass in the
+ The CassandraTemplate has many overloads for execute() and executeAsync(). Pass in the
CQL command you wish to be executed, and handle the appropriate response.
+ This example uses the basic AsynchronousQueryListener that comes with Spring Data
+ Cassandra. Please see the API documentation for all the options. There should be nothing
+ you cannot perform in Cassandra with the execute() and executeAsync() methods.
+
+ cassandraOperations.executeAsynchronously("delete from person where id = '123123123'",
+ new AsynchronousQueryListener() {
+
+ public void onQueryComplete(ResultSetFuture rsf) {
+ LOG.info("Async Query Completed");
+ }
+ });
+
+ This example shows how to create and drop a table, using different API objects, all
+ passed to the execute()
+ methods.cassandraOperations.execute("create table test_table (id uuid primary key, event text)");
+
+DropTableSpecification dropper = DropTableSpecification.dropTable("test_table");
+cassandraOperations.execute(dropper);
@@ -823,10 +920,4 @@ cassandraOperations.execute(cql);
able to catch all database related exception within a single try-catch
block.
-
-
- Execution callbacks
-
- TODO With Examples
-