From 4f70c6f19cf52bbd639140395364941974084d60 Mon Sep 17 00:00:00 2001 From: Oliver Gierke Date: Tue, 20 May 2014 21:31:52 +0200 Subject: [PATCH] DATACASS-135 - Fixed reference documentation build. Removed empty lang attributes from programlisting elements. Switched to Docbook 4.4 DTD as 4.5 is currently not supported by the Maven Docbook plugin. Fixed section identifiers. --- src/docbkx/introduction/getting-started.xml | 54 +++++---- src/docbkx/reference/cassandra.xml | 123 +++++++++++++------- 2 files changed, 108 insertions(+), 69 deletions(-) diff --git a/src/docbkx/introduction/getting-started.xml b/src/docbkx/introduction/getting-started.xml index 302c5d5a9..51826be2e 100644 --- a/src/docbkx/introduction/getting-started.xml +++ b/src/docbkx/introduction/getting-started.xml @@ -4,49 +4,53 @@ Additional Help Resources - Learning a new framework is not always straight forward. In this section, we try to provide - what we think is an easy to follow guide for starting with Spring Data Cassandra module. - However, if you encounter issues or you are just looking for an advice, feel free to use one of - the links below: + Learning a new framework is not always straight forward. In this + section, we try to provide what we think is an easy to follow guide for + starting with Spring Data Cassandra module. However, if you encounter issues + or you are just looking for an advice, feel free to use one of the links + below: -
+
Support There are a few support options available: -
+
Community Forum - The Spring Data forum - is a message board for all Spring Data (not just Cassandra) users to share - information and help each other. Note that registration is needed only - for posting. + The Spring Data forum + is a message board for all Spring Data (not just Cassandra) users to + share information and help each other. Note that registration is needed + only for posting.
-
+
Professional Support - Professional, from-the-source support, with guaranteed response time, is available from - Prowave Consulting. + Professional, from-the-source support, with guaranteed response + time, is available from Prowave + Consulting.
-
+
Following Development - For information on the Spring Data Cassandra source code repository, nightly builds and - snapshot artifacts please see the Spring Data Cassandra - homepage. + For information on the Spring Data Cassandra source code repository, + nightly builds and snapshot artifacts please see the Spring Data + Cassandra homepage. - You can help make Spring Data best serve the needs of the Spring community by interacting - with developers through the Spring Community forums. To follow developer activity look for the mailing list information on the - Spring Data Cassandra homepage. + You can help make Spring Data best serve the needs of the Spring + community by interacting with developers through the Spring Community + forums. To follow developer + activity look for the mailing list information on the Spring Data + Cassandra homepage. - If you encounter a bug or want to suggest an improvement, please create a ticket on the - Spring Data issue tracker. + If you encounter a bug or want to suggest an improvement, please + create a ticket on the Spring Data issue tracker. To stay up to date with the latest news and announcements in the Spring eco system, subscribe to the Spring Community - + Cassandra support @@ -79,7 +79,7 @@ Then add the following to pom.xml dependencies section. - <dependencies> + <dependencies> <!-- other dependency elements omitted --> @@ -93,7 +93,7 @@ Also change the version of Spring in the pom.xml to be - <spring.framework.version>3.2.8.RELEASE</spring.framework.version> + <spring.framework.version>3.2.8.RELEASE</spring.framework.version> You will also need to add the location of the Spring Milestone repository for maven to your pom.xml which is at the same level of your @@ -726,20 +726,27 @@ cassandraOperations.execute(cql);
Updating rows in a CQL table - Much like inserting, there are several flavors of update from which you can - choose. + + 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 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")); cassandraOperations.execute(update); - Then there is always the old fashioned way. You can write your own CQL - statements. + + 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); @@ -747,35 +754,50 @@ cassandraOperations.execute(cql);
Methods for removing rows - Much like inserting, there are several flavors of delete from which you can - choose. + + 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 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")); cassandraOperations.execute(delete); - Then there is always the old fashioned way. You can write your own CQL - statements. + + 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. + + 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 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. + + Then there is always the old fashioned way. You can write your own + CQL statements. + String cql = "truncate person"; cassandraOperations.execute(cql); @@ -784,32 +806,43 @@ 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. + + 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"; -List<Person> results = cassandraOperations.select(cqlAll, Person.class); +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. + + 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. + + 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>() { +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")); @@ -877,23 +910,25 @@ for (Person p : results) {
Methods for executing commands - 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'", + 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)"); + }); + + 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);