DATACASS-61 - Created DocBook Reference Guide Outline.

This commit is contained in:
David T Webb
2014-03-21 10:19:12 -04:00
parent 93c03c7262
commit dd8a89da57
10 changed files with 680 additions and 0 deletions

1
spring-cql/.gitignore vendored Normal file
View File

@@ -0,0 +1 @@
/target

80
src/docbkx/index.xml Normal file
View File

@@ -0,0 +1,80 @@
<?xml version="1.0" encoding="UTF-8"?>
<!DOCTYPE book PUBLIC "-//OASIS//DTD DocBook XML V4.4//EN"
"http://www.oasis-open.org/docbook/xml/4.4/docbookx.dtd">
<book xmlns:xi="http://www.w3.org/2001/XInclude">
<bookinfo>
<title>Spring Data Cassandra - Reference Documentation</title>
<releaseinfo>&version;</releaseinfo>
<authorgroup>
<author>
<firstname>David</firstname>
<surname>Webb</surname>
</author>
<author>
<firstname>Matthew</firstname>
<surname>Adams</surname>
</author>
<author>
<firstname>John</firstname>
<surname>McPeek</surname>
</author>
</authorgroup>
<legalnotice>
<para>Copies of this document may be made for your own use and for
distribution to others, provided that you do not charge any fee for such
copies and further provided that each copy contains this Copyright
Notice, whether distributed in print or electronically.</para>
</legalnotice>
<pubdate />
<copyright>
<year>2008-2014</year>
<holder> The original authors.</holder>
</copyright>
<productname>Spring Data Cassandra - Reference Documentation</productname>
</bookinfo>
<toc/>
<xi:include href="preface.xml"/>
<part id="introduction">
<title>Introduction</title>
<xi:include href="introduction/introduction.xml"/>
<xi:include href="introduction/requirements.xml"/>
<xi:include href="introduction/getting-started.xml"/>
<xi:include href="https://raw.github.com/spring-projects/spring-data-commons/1.7.0.RELEASE/src/docbkx/repositories.xml">
<xi:fallback href="../../../spring-data-commons/src/docbkx/repositories.xml" />
</xi:include>
</part>
<part id="reference">
<title>Reference Documentation</title>
<xi:include href="reference/introduction.xml"/>
<xi:include href="reference/cassandra.xml"/>
<xi:include href="reference/cassandra-repositories.xml"/>
<xi:include href="reference/mapping.xml"/>
</part>
<part id="appendix">
<title>Appendix</title>
<xi:include href="https://raw.github.com/spring-projects/spring-data-commons/1.7.0.RELEASE/src/docbkx/repository-namespace-reference.xml">
<xi:fallback href="../../../spring-data-commons/src/docbkx/repository-namespace-reference.xml" />
</xi:include>
<xi:include href="https://raw.github.com/spring-projects/spring-data-commons/1.7.0.RELEASE/src/docbkx/repository-query-keywords-reference.xml">
<xi:fallback href="../../../spring-data-commons/src/docbkx/repository-query-keywords-reference.xml" />
</xi:include>
</part>
</book>

View File

@@ -0,0 +1,55 @@
<?xml version="1.0" encoding="UTF-8"?>
<!DOCTYPE preface PUBLIC "-//OASIS//DTD DocBook XML V4.4//EN"
"http://www.oasis-open.org/docbook/xml/4.4/docbookx.dtd">
<chapter id="get-started">
<title>Additional Help Resources</title>
<para>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:</para>
<section id="get-started:help">
<title>Support</title>
<para>There are a few support options available:</para>
<section id="get-started:help:community">
<title>Community Forum</title>
<para>The Spring Data <ulink url="http://forum.spring.io/forum/spring-projects/data">forum
</ulink> is a message board for all Spring Data (not just Cassandra) users to share
information and help each other. Note that registration is needed <emphasis>only</emphasis>
for posting.</para>
</section>
<section id="get-started:help:professional">
<title>Professional Support</title>
<para>Professional, from-the-source support, with guaranteed response time, is available from
<ulink url="http://gopivotal.com/">Prowave Consulting</ulink>.</para>
</section>
</section>
<section id="get-started:up-to-date">
<title>Following Development</title>
<para>For information on the Spring Data Cassandra source code repository, nightly builds and
snapshot artifacts please see the <ulink
url="http://projects.spring.io/spring-data-cassandra/">Spring Data Cassandra
homepage</ulink>.</para>
<para>You can help make Spring Data best serve the needs of the Spring community by interacting
with developers through the Spring Community <ulink url="http://forum.spring.io/"
>forums</ulink>. To follow developer activity look for the mailing list information on the
Spring Data Cassandra homepage.</para>
<para>If you encounter a bug or want to suggest an improvement, please create a ticket on the
Spring Data issue <ulink url="https://jira.springframework.org/browse/DATACASS"
>tracker</ulink>.</para>
<para>To stay up to date with the latest news and announcements in the
Spring eco system, subscribe to the Spring Community <ulink
url="https://spring.io">Portal</ulink>.</para>
</section>
</chapter>

View File

@@ -0,0 +1,65 @@
<?xml version="1.0" encoding="UTF-8"?>
<!DOCTYPE book PUBLIC "-//OASIS//DTD DocBook XML V4.4//EN"
"http://www.oasis-open.org/docbook/xml/4.4/docbookx.dtd">
<partintro>
<para><para>This document is the reference guide for Spring Data - Cassandra Support. It explains
Cassandra module concepts and semantics and the syntax for various stores namespaces. </para><para>This section provides some basic introduction to Spring and the Cassandra database. The rest
of the document refers only to Spring Data Cassandra features and assumes the user is familiar
with Cassandra as well as Spring concepts. </para><section id="get-started:first-steps:spring">
<title>Knowing Spring</title>
<para>Spring Data uses Spring framework's <ulink
url="http://docs.spring.io/spring/docs/3.2.x/spring-framework-reference/html/spring-core.html">core</ulink>
functionality, such as the <ulink
url="http://docs.spring.io/spring/docs/3.2.x/spring-framework-reference/html/beans.html">IoC</ulink>
container, <ulink
url="http://docs.spring.io/spring/docs/3.2.x/spring-framework-reference/html/validation.html#core-convert">type
conversion system</ulink>, <ulink
url="http://docs.spring.io/spring/docs/3.2.x/spring-framework-reference/html/expressions.html">expression
language</ulink>, <ulink
url="http://docs.spring.io/spring/docs/3.2.x/spring-framework-reference/html/jmx.html">JMX
integration</ulink>, and portable <ulink
url="http://docs.spring.io/spring/docs/3.2.x/spring-framework-reference/html/dao.html#dao-exceptions">DAO
exception hierarchy</ulink>. While it is not important to know the
Spring APIs, understanding the concepts behind them is. At a minimum,
the idea behind IoC should be familiar for whatever IoC container you
choose to use.</para>
<para>The core functionality of the Cassandra support can be used directly, with no need to
invoke the IoC services of the Spring Container. This is much like
<classname>JdbcTemplate</classname> which can be used 'standalone' without any other
services of the Spring container. To leverage all the features of Spring Data Cassandra,
such as the repository support, you will need to configure some parts of the library using
Spring.</para>
<para>To learn more about Spring, you can refer to the comprehensive
(and sometimes disarming) documentation that explains in detail the
Spring Framework. There are a lot of articles, blog entries and books on
the matter - take a look at the Spring framework <ulink
url="https://spring.io/docs">home page </ulink> for
more information.</para>
</section><section id="get-started:first-steps:nosql">
<title>Knowing NoSQL and Cassandra</title>
<para>NoSQL stores have taken the storage world by storm. It is a vast domain with a plethora
of solutions, terms and patterns (to make things worth even the term itself has multiple
<ulink url="http://www.google.com/search?q=nosoql+acronym">meanings</ulink>). While some
of the principles are common, it is crucial that the user is familiar to some degree with
the Cassandra Columnar NoSQL Datastore supported by DATACASS. The best way to get acquainted
to this solutions is to read their documentation and follow their examples - it usually
doesn't take more then 5-10 minutes to go through them and if you are coming from an
RDMBS-only background many times these exercises can be an eye opener.</para>
<para>The jumping off ground for learning about Cassandra is <ulink
url="http://cassandra.apache.org/">cassandra.apache.org/</ulink>. Here is a list of other
useful resources.</para>
<itemizedlist>
<listitem>
<para>The <ulink url="http://planetcassandra.org/">Planet Cassandra</ulink> site has many
valuable resources for Cassandra best practices.</para>
<para>The <ulink url="http://datastax.com/">DataStax</ulink> site offers commercial support and many resources.</para>
</listitem>
</itemizedlist>
</section></para>
</partintro>

View File

@@ -0,0 +1,12 @@
<chapter id="requirements">
<title>Requirements</title>
<para>Spring Data Cassandra 1.x binaries requires JDK level 6.0 and above,
and
<ulink url="https://spring.io/docs">Spring Framework</ulink>
3.2.x and above.
</para>
<para>
Currently we support Cassandra 1.X using the DataStax Java Driver (1.0.6-dse)
</para>
</chapter>

13
src/docbkx/preface.xml Normal file
View File

@@ -0,0 +1,13 @@
<?xml version="1.0" encoding="UTF-8"?>
<!DOCTYPE preface PUBLIC "-//OASIS//DTD DocBook XML V4.4//EN"
"http://www.oasis-open.org/docbook/xml/4.4/docbookx.dtd">
<preface id="preface">
<title>Preface</title>
<para>The Spring Data Cassandra project applies core Spring concepts to
the development of solutions using the Cassandra Columnar data store.
We provide a "template" as a high-level abstraction for storing and querying
documents. You will notice similarities to the JDBC support in the Spring
Framework.
</para>
</preface>

View File

@@ -0,0 +1,58 @@
<?xml version="1.0" encoding="UTF-8"?>
<!DOCTYPE chapter PUBLIC "-//OASIS//DTD DocBook XML V4.4//EN"
"http://www.oasis-open.org/docbook/xml/4.4/docbookx.dtd">
<chapter id="cassandra.repositories">
<title>Cassandra repositories</title>
<section id="cassandra-repo-intro">
<title>Introduction</title>
<para>This chapter will point out the specialties for repository support
for Cassandra. This builds on the core repository support explained in <xref
linkend="repositories"/>. So make sure you've got a sound understanding of
the basic concepts explained there.</para>
</section>
<section id="cassandra-repo-usage">
<title>Usage</title>
<para>To access domain entities stored in a Cassandra you can leverage our
sophisticated repository support that eases implementing those quite
significantly. To do so, simply create an interface for your
repository:</para>
<para>TODO</para>
</section>
<section id="cassandradb.repositories.queries">
<title>Query methods</title>
<section id="cassandradb.repositories.queries.delete">
<title>Repository delete queries</title>
</section>
</section>
<section id="cassandradb.repositories.misc">
<title>Miscellaneous</title>
<section id="cassandradb.repositories.misc.cdi-integration">
<title>CDI Integration</title>
<para>The Spring Data Cassandra CDI extension will pick up the
<classname>CassandraTemplate</classname> available as CDI bean and create a proxy for a
Spring Data repository whenever an bean of a repository type is requested by the container.
Thus obtaining an instance of a Spring Data repository is a matter of declaring an
<code>@Inject</code>-ed property:</para>
<programlisting language="java">class RepositoryClient {
@Inject
PersonRepository repository;
public void businessMethod() {
List&lt;Person&gt; people = repository.findAll();
}
}</programlisting>
</section>
</section>
</chapter>

View File

@@ -0,0 +1,245 @@
<?xml version="1.0" encoding="UTF-8"?>
<!DOCTYPE chapter PUBLIC "-//OASIS//DTD DocBook XML V4.4//EN"
"http://www.oasis-open.org/docbook/xml/4.4/docbookx.dtd">
<chapter id="mongo.core">
<title>Cassandra support</title>
<para>The Cassandra support contains a wide range of features which are summarized below.</para>
<itemizedlist>
<listitem>
<para>Spring configuration support using Java based @Configuration classes or an XML namespace
for a Cassandra driver instance and replica sets</para>
</listitem>
<listitem>
<para>CassandraTemplate helper class that increases productivity performing common Cassandra
operations. Includes integrated object mapping between CQL Tables and POJOs.</para>
</listitem>
<listitem>
<para>Exception translation into Spring's portable Data Access Exception
hierarchy</para>
</listitem>
<listitem>
<para>Feature Rich Object Mapping integrated with Spring's Conversion
Service</para>
</listitem>
<listitem>
<para>Annotation based mapping metadata but extensible to support other
metadata formats</para>
</listitem>
<listitem>
<para>Persistence and mapping lifecycle events</para>
</listitem>
<listitem>
<para>Java based Query, Criteria, and Update DSLs</para>
</listitem>
<listitem>
<para>Automatic implementation of Repository interfaces including
support for custom finder methods.</para>
</listitem>
</itemizedlist>
<para>For most tasks you will find yourself using <classname>CassandraTemplate</classname> or the
Repository support that both leverage the rich mapping functionality. CassandraTemplate is the
place to look for accessing functionality such as incrementing counters or ad-hoc CRUD
operations. CassandraTemplate also provides callback methods so that it is easy for you to get a
hold of the low level API artifacts such as <literal>com.datastax.driver.core.Session</literal>
to communicate directly with Cassandra. The goal with naming conventions on various API
artifacts is to copy those in the base DataStax Java driver so you can easily map your existing
knowledge onto the Spring APIs.</para>
<section id="mongodb-getting-started">
<title>Getting Started</title>
<para>Spring Cassandra support requires Cassanra 1.1 or higher (but not Cassandra 2.0) and Java
SE 6 or higher. The latest commerical release (1.2.X as of this writing) is recommended. An
easy way to bootstrap setting up a working environment is to create a Spring based project in
<ulink url="http://spring.io/tools/sts">STS</ulink>.</para>
<para>First you need to set up a running Cassandra server. </para>
<para>To create a Spring project in STS go to File -&gt; New -&gt; Spring Template Project -&gt;
Simple Spring Utility Project -&gt; press Yes when prompted. Then enter a project and a
package name such as org.spring.cassandra.example.</para>
<para>Then add the following to pom.xml dependencies section.</para>
<programlisting lang="" language="xml">&lt;dependencies&gt;
&lt;!-- other dependency elements omitted --&gt;
&lt;dependency&gt;
&lt;groupId&gt;org.springframework.data&lt;/groupId&gt;
&lt;artifactId&gt;spring-data-cassandra&lt;/artifactId&gt;
&lt;version&gt;1.0.0.RELEASE&lt;/version&gt;
&lt;/dependency&gt;
&lt;/dependencies&gt;</programlisting>
<para>Also change the version of Spring in the pom.xml to be</para>
<programlisting lang="" language="xml">&lt;spring.framework.version&gt;3.2.8.RELEASE&lt;/spring.framework.version&gt;</programlisting>
<para>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
&lt;dependencies/&gt; element</para>
<programlisting language="xml">&lt;repositories&gt;
&lt;repository&gt;
&lt;id&gt;spring-milestone&lt;/id&gt;
&lt;name&gt;Spring Maven MILESTONE Repository&lt;/name&gt;
&lt;url&gt;http://repo.spring.io/libs-milestone&lt;/url&gt;
&lt;/repository&gt;
&lt;/repositories&gt;</programlisting>
<para>The repository is also <ulink
url="http://shrub.appspot.com/maven.springframework.org/milestone/org/springframework/data/">browseable
here</ulink>.</para>
<para>TODO</para>
</section>
<section id="mongo.examples-repo">
<title>Examples Repository</title>
<para>TODO</para>
</section>
<section id="mongodb-connectors">
<title>Connecting to Cassandra with Spring</title>
</section>
<section id="mongo.auditing">
<title>General auditing configuration</title>
<para>Auditing support is not available in the current version.</para>
</section>
<section id="mongo-template">
<title>Introduction to CassandraTemplate</title>
<section id="mongo-template.instantiating" label=" ">
<title>Instantiating CassandraTemplate</title>
</section>
</section>
<section id="mongo-template.save-update-remove">
<title>Saving, Updating, and Removing Rows</title>
<para><classname>CassandraTemplate</classname> provides a simple way for you to save, update,
and delete your domain objects and map those objects to documents stored in Cassandra.</para>
<section id="mongo-template.id-handling">
<title>How the Composite Primary Key fields are handled in the mapping layer</title>
<para>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.</para>
<para>TODO With Examples</para>
</section>
<section id="mongo-template.type-mapping">
<title>Type mapping</title>
</section>
<section id="mongo-template.save-insert">
<title>Methods for saving and inserting rows</title>
</section>
<section id="mongodb-template-update">
<title>Updating rows in a CQL table</title>
</section>
<section id="mongo-template.upserts">
<title>Upserting rows in a CQL table</title>
</section>
<section id="mongo-template.find-and-upsert">
<title>Finding and Upserting rowa in a CQL table</title>
</section>
<section id="mongo-template.delete">
<title>Methods for removing rows</title>
</section>
</section>
<section id="mongo.query">
<title>Querying CQL Tables</title>
</section>
<section id="mongo.custom-converters">
<title>Overriding default mapping with custom converters</title>
<para>In order to have more fine grained control over the mapping process you can register
Spring converters with the <classname>CassandraConverter</classname> implementations such as
the <classname>MappingCassandraConverter</classname>.</para>
<para>The <classname>MappingCassandraConverter</classname> checks to see if there are any Spring
converters that can handle a specific class before attempting to map the object itself. To
'hijack' the normal mapping strategies of the
<classname>MappingCassandraConverter</classname>, perhaps for increased performance or other
custom mapping needs, you first need to create an implementation of the Spring
<interfacename>Converter</interfacename> interface and then register it with the
MappingConverter.</para>
<note>
<para>For more information on the Spring type conversion service see the
reference docs <ulink
url="http://docs.spring.io/spring/docs/current/spring-framework-reference/html/validation.html#core-convert">here</ulink>.</para>
</note>
<section id="mongo.custom-converters.writer">
<title>Saving using a registered Spring Converter</title>
</section>
<section id="mongo.custom-converters.reader">
<title>Reading using a Spring Converter</title>
</section>
<section id="mongo.custom-converters.xml">
<title>Registering Spring Converters with the CassandraConverter</title>
</section>
<section id="mongo.converter-disambiguation">
<title>Converter disambiguation</title>
</section>
</section>
<section id="mongo-template.commands">
<title>Executing Commands</title>
<section id="mongo-template.commands.execution">
<title>Methods for executing commands</title>
</section>
</section>
<section id="mongodb.mapping-usage.events">
<title>Lifecycle Events</title>
</section>
<section id="mongo.exception">
<title>Exception Translation</title>
<para>The Spring framework provides exception translation for a wide variety of database and
mapping technologies. This has traditionally been for JDBC and JPA. The Spring support for
Cassandra extends this feature to the Cassandra Database by providing an implementation of the
<classname>org.springframework.dao.support.PersistenceExceptionTranslator</classname>
interface.</para>
<para>The motivation behind mapping to Spring's <ulink
url="http://docs.spring.io/spring/docs/current/spring-framework-reference/html/dao.html#dao-exceptions"
>consistent data access exception hierarchy</ulink> is that you are then able to write
portable and descriptive exception handling code without resorting to coding against Cassandra
Exceptions. All of Spring's data access exceptions are inherited from the root
<classname>DataAccessException</classname> class so you can be sure that you will be able to
catch all database related exception within a single try-catch block. </para>
</section>
<section id="mongo.executioncallback">
<title>Execution callbacks</title>
</section>
</chapter>

View File

@@ -0,0 +1,21 @@
<?xml version="1.0" encoding="UTF-8"?>
<!DOCTYPE book PUBLIC "-//OASIS//DTD DocBook XML V4.4//EN"
"http://www.oasis-open.org/docbook/xml/4.4/docbookx.dtd">
<partintro>
<title>Document Structure</title>
<para>This part of the reference documentation explains the core functionality
offered by Spring Data Cassandra.
</para>
<para>
<xref linkend="cassandra.core"/>
introduces the Cassandra module feature set.
</para>
<para>
<xref linkend="cassandra.repositories"/>
introduces the repository support for Cassandra.
</para>
</partintro>

View File

@@ -0,0 +1,130 @@
<?xml version="1.0" encoding="UTF-8"?>
<!DOCTYPE chapter PUBLIC "-//OASIS//DTD DocBook XML V4.4//EN"
"http://www.oasis-open.org/docbook/xml/4.4/docbookx.dtd">
<chapter id="mapping-chapter">
<title>Mapping</title>
<para>
Rich mapping support is provided by the
<classname>CassandraMappingConverter</classname>
.
<classname>CassandraMappingConverter</classname>
has a rich metadata model that
provides a full feature set of
functionality to map domain objects to
CQL Tables. The mapping metadata
model is populated using annotations
on your domain objects. However,
the infrastructure is not limited to
using
annotations as the only
source of metadata information. The
<classname>CassandraMappingConverter</classname>
also allows you to map objects
to documents without providing any
additional metadata, by following a
set
of conventions.
</para>
<para>In this section we will describe the features of the
CassandraMappingConverter. How to use conventions for mapping objects
to
documents and how to override those conventions with annotation
based
mapping metadata.
</para>
<section id="mapping-conventions">
<title>Convention based Mapping</title>
<para>
<classname>CassandraMappingConverter</classname>
has a few conventions
for mapping objects to CQL Tables when no
additional mapping metadata is
provided. The conventions are:
</para>
<itemizedlist>
<listitem>
<para>
The short Java class name is mapped to the table name in
the
following manner. The class
'
<classname>com.bigbank.SavingsAccount</classname>
' maps to
'
<literal>savings_account</literal>
' table name.
</para>
</listitem>
<listitem>
<para>The converter will use any Spring Converters registered with
it
to override the default mapping of object properties to document
field/values.
</para>
</listitem>
<listitem>
<para>The fields of an object are used to convert to and from fields
in the document. Public JavaBean properties are not used.
</para>
</listitem>
</itemizedlist>
<section id="mapping.conventions.id-field">
<title>How the CQL Composite Primary Key fields are handled in the
mapping layer
</title>
<para>TODO</para>
</section>
<section id="mapping-configuration">
<title>Mapping Configuration</title>
<para>
Unless explicitly configured, an instance of
<classname>CassandraMappingConverter</classname>
is created by default when
creating a
<classname>CassandraTemplate</classname>
. You can create your own
instance of the
<classname>MappingCassandraConverter</classname>
so as to tell it where to scan the classpath at startup your domain
classes in order
to extract metadata and construct indexes. Also, by
creating your own
instance you can register Spring converters to use
for mapping specific
classes to and from the database.
</para>
<para>
You can configure the
<classname>CassandraMappingConverter</classname>
and CassandraTemplate
either using Java or XML based metadata. Here
is an
example using Spring's
Java based configuration
</para>
<example>
<title>@Configuration class to configure Cassandra mapping support
</title>
<para>TODO</para>
</example>
<example>
<title>XML schema to configure Cassandra mapping support</title>
<para>TODO</para>
</example>
</section>
</section>
</chapter>