DATACASS-673 - Revise readme for a consistent structure.
This commit is contained in:
45
CI.adoc
Normal file
45
CI.adoc
Normal file
@@ -0,0 +1,45 @@
|
||||
= Continuous Integration
|
||||
|
||||
image:https://jenkins.spring.io/buildStatus/icon?job=spring-data-cassandra%2Fmaster&subject=Moore%20(master)[link=https://jenkins.spring.io/view/SpringData/job/spring-data-cassandra/]
|
||||
image:https://jenkins.spring.io/buildStatus/icon?job=spring-data-cassandra%2F2.1.x&subject=Lovelace%20(2.1.x)[link=https://jenkins.spring.io/view/SpringData/job/spring-data-cassandra/]
|
||||
image:https://jenkins.spring.io/buildStatus/icon?job=spring-data-cassandra%2F1.5.x&subject=Ingalls%20(1.5.x)[link=https://jenkins.spring.io/view/SpringData/job/spring-data-cassandra/]
|
||||
|
||||
== Running CI tasks locally
|
||||
|
||||
Since this pipeline is purely Docker-based, it's easy to:
|
||||
|
||||
* Debug what went wrong on your local machine.
|
||||
* Test out a a tweak to your `test.sh` script before sending it out.
|
||||
* Experiment against a new image before submitting your pull request.
|
||||
|
||||
All of these use cases are great reasons to essentially run what the CI server does on your local machine.
|
||||
|
||||
IMPORTANT: To do this you must have Docker installed on your machine.
|
||||
|
||||
1. `docker run -it --mount type=bind,source="$(pwd)",target=/spring-data-cassandra-github adoptopenjdk/openjdk8:latest /bin/bash`
|
||||
+
|
||||
This will launch the Docker image and mount your source code at `spring-data-cassandra-github`.
|
||||
+
|
||||
2. `cd spring-data-cassandra-github`
|
||||
+
|
||||
Next, run your tests from inside the container:
|
||||
+
|
||||
3. `./mvnw clean dependency:list test -Dsort` (or whatever profile you need to test out)
|
||||
|
||||
Since the container is binding to your source, you can make edits from your IDE and continue to run build jobs.
|
||||
|
||||
If you need to test the `build.sh` script, do this:
|
||||
|
||||
1. `docker run -it --mount type=bind,source="$(pwd)",target=/spring-data-cassandra-github adoptopenjdk/openjdk8:latest /bin/bash`
|
||||
+
|
||||
This will launch the Docker image and mount your source code at `spring-data-cassandra-github`.
|
||||
+
|
||||
2. `cd spring-data-cassandra-github`
|
||||
+
|
||||
Next, try to package everything up from inside the container:
|
||||
+
|
||||
3. `./mvnw -Pci,snapshot -Dmaven.test.skip=true clean deploy`
|
||||
|
||||
IMPORTANT: This will attempt to deploy to artifactory, but without credentials, it will fail, leaving you simply with a built artifact.
|
||||
|
||||
NOTE: Docker containers can eat up disk space fast! From time to time, run `docker system prune` to clean out old images.
|
||||
256
README.adoc
256
README.adoc
@@ -1,78 +1,34 @@
|
||||
image:https://spring.io/badges/spring-data-cassandra/ga.svg[Spring Data for Apache Cassandra,link=https://projects.spring.io/spring-data-cassandra/#quick-start]
|
||||
image:https://spring.io/badges/spring-data-cassandra/snapshot.svg[Spring Data for Apache Cassandra,link=https://projects.spring.io/spring-data-cassandra/#quick-start]
|
||||
|
||||
image:https://jenkins.spring.io/buildStatus/icon?job=spring-data-cassandra%2Fmaster&subject=Moore%20(master)[link=https://jenkins.spring.io/view/SpringData/job/spring-data-cassandra/]
|
||||
image:https://jenkins.spring.io/buildStatus/icon?job=spring-data-cassandra%2F2.1.x&subject=Lovelace%20(2.1.x)[link=https://jenkins.spring.io/view/SpringData/job/spring-data-cassandra/]
|
||||
image:https://jenkins.spring.io/buildStatus/icon?job=spring-data-cassandra%2F1.5.x&subject=Ingalls%20(1.5.x)[link=https://jenkins.spring.io/view/SpringData/job/spring-data-cassandra/]
|
||||
|
||||
= Spring Data for Apache Cassandra
|
||||
= Spring Data for Apache Cassandra image:https://jenkins.spring.io/buildStatus/icon?job=spring-data-cassandra%2Fmaster&subject=Build[link=https://jenkins.spring.io/view/SpringData/job/spring-data-cassandra/] https://gitter.im/spring-projects/spring-data[image:https://badges.gitter.im/spring-projects/spring-data.svg[Gitter]]
|
||||
|
||||
The primary goal of the https://projects.spring.io/spring-data[Spring Data] project is to make it easier to build Spring-powered applications that use new data access technologies such as non-relational databases, map-reduce frameworks, and cloud based data services.
|
||||
|
||||
The Spring Data for Apache Cassandra project aims to provide a familiar and consistent Spring-based programming model for new datastores while retaining store-specific features and capabilities. The Spring Data for Apache Cassandra project provides integration with the Apache Cassandra database. Key functional areas of Spring Data for Apache Cassandra are a CQL abstraction, a POJO centric model for interacting with an Apache Cassandra tables and easily writing a repository style data access layer.
|
||||
The Apache Cassandra NoSQL Database offers many new capabilities for teams seeking a solution to handle high velocity, high volume and variable data flows.
|
||||
This new way of thinking introduces new concepts and a learning curve that can be intimidating to team members and team managers. Spring Data for Apache Cassandra offers a familiar interface to those who have used other Spring Data modules in the past.
|
||||
|
||||
== Getting Help
|
||||
The learning curve for developing applications with Apache Cassandra is significantly reduced when using Spring Data for Apache Cassandra.
|
||||
With the power to stay at a high level with annotated POJOs, or at a low level with high performance data ingestion capabilities, the Spring Data for Apache Cassandra templates are sure to meet every application need.
|
||||
|
||||
For a comprehensive treatment of all the Spring Data for Apache Cassandra features, please refer to:
|
||||
== Features
|
||||
|
||||
* the https://docs.spring.io/spring-data/cassandra/docs/current/reference/html/[User Guide]
|
||||
* the https://docs.spring.io/spring-data/cassandra/docs/current/api/[JavaDocs] have extensive comments in them as well.
|
||||
* the home page of https://projects.spring.io/spring-data-cassandra[Spring Data for Apache Cassandra] contains links to articles and other resources.
|
||||
* for more detailed questions, use https://stackoverflow.com/questions/tagged/spring-data-cassandra[Spring Data for Apache Cassandra on Stackoverflow].
|
||||
* Build repositories based on common Spring Data interfaces
|
||||
* Support for synchronous, reactive, and asynchronous data operations
|
||||
* Support for XML based Keyspace creation and CQL Table creation
|
||||
* JavaConfig and XML Support for all Cluster and Session Capabilities
|
||||
* Exception Translation to the familiar Spring DataAccessException hierarchy
|
||||
* Convenient QueryBuilders to eliminate the need to learn CQL
|
||||
* Automatic implementation of Repository interfaces including support for custom query methods
|
||||
* Based on the 3.x DataStax CQL Java Driver
|
||||
|
||||
If you are new to Spring as well as to Spring Data, look for information about https://projects.spring.io/[Spring projects].
|
||||
== Code of Conduct
|
||||
|
||||
== Quick Start
|
||||
This project is governed by the link:CODE_OF_CONDUCT.adoc[Spring Code of Conduct]. By participating, you are expected to uphold this code of conduct. Please report unacceptable behavior to spring-code-of-conduct@pivotal.io.
|
||||
|
||||
Prerequisites:
|
||||
* Java 6
|
||||
* https://docs.datastax.com/en/developer/driver-matrix/doc/javaDrivers.html[DataStax Java Driver for Apache Cassandra 3.x]
|
||||
* Apache Cassandra 1.x, 2.x or 3.x
|
||||
== Getting Started
|
||||
|
||||
=== Maven configuration
|
||||
|
||||
Add the Maven dependency:
|
||||
|
||||
[source,xml]
|
||||
----
|
||||
<dependency>
|
||||
<groupId>org.springframework.data</groupId>
|
||||
<artifactId>spring-data-cassandra</artifactId>
|
||||
<version>${version}.RELEASE</version>
|
||||
</dependency>
|
||||
----
|
||||
|
||||
If you would rather like the latest snapshots of the upcoming major version, use our Maven snapshot repository and declare the appropriate dependency version.
|
||||
|
||||
[source,xml]
|
||||
----
|
||||
<dependency>
|
||||
<groupId>org.springframework.data</groupId>
|
||||
<artifactId>spring-data-cassandra</artifactId>
|
||||
<version>${version}.BUILD-SNAPSHOT</version>
|
||||
</dependency>
|
||||
|
||||
<repository>
|
||||
<id>spring-libs-snapshot</id>
|
||||
<name>Spring Snapshot Repository</name>
|
||||
<url>https://repo.spring.io/libs-snapshot</url>
|
||||
</repository>
|
||||
----
|
||||
|
||||
=== CassandraTemplate
|
||||
|
||||
`CassandraTemplate` is the central support class for Cassandra database operations. It provides:
|
||||
|
||||
* Increased productivity by handling common Cassandra operations properly. Includes integrated object mapping between CQL Tables and POJOs.
|
||||
* Exception translation into Spring's https://docs.spring.io/spring/docs/current/spring-framework-reference/html/dao.html#dao-exceptions[technology agnostic DAO exception hierarchy].
|
||||
* Feature rich object mapping integrated with Spring’s Conversion Service.
|
||||
* Annotation-based mapping metadata but extensible to support other metadata formats.
|
||||
|
||||
=== Spring Data repositories
|
||||
|
||||
To simplify the creation of data repositories Spring Data for Apache Cassandra provides a generic repository programming model. It will automatically create a repository proxy for you that adds implementations of finder methods you specify on an interface.
|
||||
|
||||
For example, given a `Person` class with first and last name properties, a `PersonRepository` interface that can query for `Person` by last name and when the first name matches a like expression is shown below:
|
||||
Here is a quick teaser of an application using Spring Data Repositories in Java:
|
||||
|
||||
[source,java]
|
||||
----
|
||||
@@ -82,14 +38,30 @@ public interface PersonRepository extends CrudRepository<Person, Long> {
|
||||
|
||||
List<Person> findByFirstnameLike(String firstname);
|
||||
}
|
||||
----
|
||||
|
||||
The queries issued on execution will be derived from the method name. Extending `CrudRepository` causes CRUD methods being pulled into the interface so that you can easily save and find single entities and collections of them.
|
||||
@Service
|
||||
public class MyService {
|
||||
|
||||
You can have Spring automatically create a proxy for the interface by using the following JavaConfig:
|
||||
private final PersonRepository repository;
|
||||
|
||||
public MyService(PersonRepository repository) {
|
||||
this.repository = repository;
|
||||
}
|
||||
|
||||
public void doWork() {
|
||||
|
||||
repository.deleteAll();
|
||||
|
||||
Person person = new Person();
|
||||
person.setFirstname("Matthew");
|
||||
person.setLastname("Adams");
|
||||
repository.save(person);
|
||||
|
||||
List<Person> lastNameResults = repository.findByLastname("Adams");
|
||||
List<Person> firstNameResults = repository.findByFirstnameLike("M*");
|
||||
}
|
||||
}
|
||||
|
||||
[source,java]
|
||||
----
|
||||
@Configuration
|
||||
@EnableCassandraRepositories
|
||||
class ApplicationConfig extends AbstractCassandraConfiguration {
|
||||
@@ -106,127 +78,97 @@ class ApplicationConfig extends AbstractCassandraConfiguration {
|
||||
}
|
||||
----
|
||||
|
||||
This sets up a connection to a local Apache Cassandra instance and enables the detection of Spring Data repositories (through `@EnableCassandraRepositories`). The same configuration would look like this in XML:
|
||||
=== Maven configuration
|
||||
|
||||
Add the Maven dependency:
|
||||
|
||||
[source,xml]
|
||||
----
|
||||
<cassandra:cluster contact-points="localhost" port="9042" />
|
||||
|
||||
<cassandra:session keyspace-name="springdata" />
|
||||
|
||||
<cassandra:template id="cassandraTemplate" />
|
||||
|
||||
<cassandra:repositories base-package="com.acme.repository" />
|
||||
<dependency>
|
||||
<groupId>org.springframework.data</groupId>
|
||||
<artifactId>spring-data-cassandra</artifactId>
|
||||
<version>${version}.RELEASE</version>
|
||||
</dependency>
|
||||
----
|
||||
|
||||
This will find the repository interface and register a proxy object in the container. You can use it as shown below:
|
||||
If you'd rather like the latest snapshots of the upcoming major version, use our Maven snapshot repository and declare the appropriate dependency version.
|
||||
|
||||
[source,java]
|
||||
[source,xml]
|
||||
----
|
||||
@Service
|
||||
public class MyService {
|
||||
<dependency>
|
||||
<groupId>org.springframework.data</groupId>
|
||||
<artifactId>spring-data-cassandra</artifactId>
|
||||
<version>${version}.BUILD-SNAPSHOT</version>
|
||||
</dependency>
|
||||
|
||||
private final PersonRepository repository;
|
||||
|
||||
@Autowired
|
||||
public MyService(PersonRepository repository) {
|
||||
this.repository = repository;
|
||||
}
|
||||
|
||||
public void doWork() {
|
||||
|
||||
repository.deleteAll();
|
||||
|
||||
Person person = new Person();
|
||||
person.setFirstname("Oliver");
|
||||
person.setLastname("Gierke");
|
||||
person = repository.save(person);
|
||||
|
||||
List<Person> lastNameResults = repository.findByLastname("Gierke");
|
||||
List<Person> firstNameResults = repository.findByFirstnameLike("Oli*");
|
||||
}
|
||||
}
|
||||
<repository>
|
||||
<id>spring-libs-snapshot</id>
|
||||
<name>Spring Snapshot Repository</name>
|
||||
<url>https://repo.spring.io/libs-snapshot</url>
|
||||
</repository>
|
||||
----
|
||||
|
||||
== What's included
|
||||
== Getting Help
|
||||
|
||||
Spring Data for Apache Cassandra consists of two modules:
|
||||
Having trouble with Spring Data? We’d love to help!
|
||||
|
||||
* Spring CQL
|
||||
* Spring Data for Apache Cassandra
|
||||
* Check the
|
||||
https://docs.spring.io/spring-data/cassandra/docs/current/reference/html/[reference documentation], and https://docs.spring.io/spring-data/cassandra/docs/current/api/[Javadocs].
|
||||
* Learn the Spring basics – Spring Data builds on Spring Framework, check the https://spring.io[spring.io] web-site for a wealth of reference documentation.
|
||||
If you are just starting out with Spring, try one of the https://spring.io/guides[guides].
|
||||
* If you are upgrading, check out the https://docs.spring.io/spring-data/cassandra/docs/current/changelog.txt[changelog] for "`new and noteworthy`" features.
|
||||
* Ask a question - we monitor https://stackoverflow.com[stackoverflow.com] for questions tagged with https://stackoverflow.com/tags/spring-data[`spring-data-cassandra`].
|
||||
You can also chat with the community on https://gitter.im/spring-projects/spring-data[Gitter].
|
||||
* Report bugs with Spring Data Cassandra at https://jira.spring.io/browse/DATACASS[jira.spring.io/browse/DATACASS].
|
||||
|
||||
You can choose among several approaches to form the basis for your Cassandra database access. Spring’s support for Apache Cassandra comes in different flavors. Once you start using one of these approaches, you can still mix and match to include a feature from a different approach.
|
||||
== Reporting Issues
|
||||
|
||||
=== Spring CQL
|
||||
Spring Data uses JIRA as issue tracking system to record bugs and feature requests. If you want to raise an issue, please follow the recommendations below:
|
||||
|
||||
Spring CQL takes care of all the low-level details that can make Cassandra and CQL such a tedious API to develop with.
|
||||
* Before you log a bug, please search the
|
||||
https://jira.spring.io/browse/DATACASS[issue tracker] to see if someone has already reported the problem.
|
||||
* If the issue doesn’t already exist, https://jira.spring.io/browse/DATACASS[create a new issue].
|
||||
* Please provide as much information as possible with the issue report, we like to know the version of Spring Data that you are using and JVM version.
|
||||
* If you need to paste code, or include a stack trace use JIRA `{code}…{code}` escapes before and after your text.
|
||||
* If possible try to create a test-case or project that replicates the issue. Attach a link to your code or a compressed file containing your code.
|
||||
|
||||
`CqlTemplate` is the classic Spring CQL approach and the most popular. This "lowest level" approach and all others use a `CqlTemplate` under the covers including schema generation support.
|
||||
== Building from Source
|
||||
|
||||
=== Spring Data Cassandra
|
||||
You don’t need to build from source to use Spring Data (binaries in https://repo.spring.io[repo.spring.io]), but if you want to try out the latest and greatest, Spring Data can be easily built with the https://github.com/takari/maven-wrapper[maven wrapper].
|
||||
You also need JDK 1.8.
|
||||
|
||||
Spring Data for Apache Cassandra adds object mapping, schema generation and repository support to the feature set.
|
||||
[source,bash]
|
||||
----
|
||||
$ ./mvnw clean install
|
||||
----
|
||||
|
||||
`CassandraTemplate` wraps a `CqlTemplate` to provide result to object mapping and the use of `SELECT`, `INSERT`, `UPDATE` and `DELETE` methods instead of writing CQL statements. This approach provides better documentation and ease of use. Schema generation support supports fast bootstrapping by using mapped objects to create tables and user types.
|
||||
If you want to build with the regular `mvn` command, you will need https://maven.apache.org/run-maven/index.html[Maven v3.5.0 or above].
|
||||
|
||||
== Contributing to Spring Data
|
||||
|
||||
Here are some ways for you to get involved in the community:
|
||||
|
||||
* Get involved with the Spring community on Stackoverflow and help out on the https://stackoverflow.com/questions/tagged/spring-data-cassandra[spring-data-cassandra] tag by responding to questions and joining the debate.
|
||||
* Create https://jira.spring.io/browse/DATACASS[JIRA] tickets for bugs and new features and comment and vote on the ones that you are interested in.
|
||||
* Github is for social coding: if you want to write code, we encourage contributions through pull requests from https://help.github.com/forking/[forks of this repository]. If you want to contribute code this way, please reference a JIRA ticket as well covering the specific issue you are addressing.
|
||||
* Watch for upcoming articles on Spring by https://spring.io/blog[subscribing] to spring.io.
|
||||
|
||||
Before we accept a non-trivial patch or pull request we will need you to https://cla.pivotal.io/sign/spring[sign the Contributor License Agreement]. Signing the contributor’s agreement does not grant anyone commit rights to the main repository, but it does mean that we can accept your contributions, and you will get an author credit if we do. If you forget to do so, you'll be reminded when you submit a pull request. Active contributors might be asked to join the core team, and given the ability to merge pull requests.
|
||||
_Also see link:CONTRIBUTING.adoc[CONTRIBUTING.adoc] if you wish to submit pull requests, and in particular please sign the https://cla.pivotal.io/sign/spring[Contributor’s Agreement] before your first change, is trivial._
|
||||
|
||||
== Initial Contributors
|
||||
|
||||
Spring Data for Apache Cassandra was initially created and supported by the following
|
||||
companies and individuals:
|
||||
Spring Data for Apache Cassandra was initially created and supported by the following companies and individuals:
|
||||
|
||||
* David Webb
|
||||
* Matthew Adams
|
||||
* John McPeek
|
||||
* http://www.prowaveconsulting.com[Prowave Consulting] - David Webb
|
||||
* http://www.scispike.com[SciSpike] - Matthew Adams
|
||||
* John McPeek
|
||||
|
||||
== Running CI tasks locally
|
||||
=== Building reference documentation
|
||||
|
||||
Since this pipeline is purely Docker-based, it's easy to:
|
||||
Building the documentation builds also the project without running tests.
|
||||
|
||||
* Debug what went wrong on your local machine.
|
||||
* Test out a a tweak to your `test.sh` script before sending it out.
|
||||
* Experiment against a new image before submitting your pull request.
|
||||
[source,bash]
|
||||
----
|
||||
$ ./mvnw clean install -Pdistribute
|
||||
----
|
||||
|
||||
All of these use cases are great reasons to essentially run what the CI server does on your local machine.
|
||||
The generated documentation is available from `target/site/reference/html/index.html`.
|
||||
|
||||
IMPORTANT: To do this you must have Docker installed on your machine.
|
||||
== Examples
|
||||
|
||||
1. `docker run -it --mount type=bind,source="$(pwd)",target=/spring-data-cassandra-github adoptopenjdk/openjdk8:latest /bin/bash`
|
||||
+
|
||||
This will launch the Docker image and mount your source code at `spring-data-cassandra-github`.
|
||||
+
|
||||
2. `cd spring-data-cassandra-github`
|
||||
+
|
||||
Next, run your tests from inside the container:
|
||||
+
|
||||
3. `./mvnw clean dependency:list test -Dsort` (or whatever profile you need to test out)
|
||||
* https://github.com/spring-projects/spring-data-examples/[Spring Data Examples] contains example projects that explain specific features in more detail.
|
||||
|
||||
Since the container is binding to your source, you can make edits from your IDE and continue to run build jobs.
|
||||
== License
|
||||
|
||||
If you need to test the `build.sh` script, do this:
|
||||
|
||||
1. `docker run -it --mount type=bind,source="$(pwd)",target=/spring-data-cassandra-github adoptopenjdk/openjdk8:latest /bin/bash`
|
||||
+
|
||||
This will launch the Docker image and mount your source code at `spring-data-cassandra-github`.
|
||||
+
|
||||
2. `cd spring-data-cassandra-github`
|
||||
+
|
||||
Next, try to package everything up from inside the container:
|
||||
+
|
||||
3. `./mvnw -Pci,snapshot -Dmaven.test.skip=true clean deploy`
|
||||
|
||||
IMPORTANT: This will attempt to deploy to artifactory, but without credentials, it will fail, leaving you simply with a built artifact.
|
||||
|
||||
NOTE: Docker containers can eat up disk space fast! From time to time, run `docker system prune` to clean out old images.
|
||||
Spring Data for Apache Cassandra is Open Source software released under the https://www.apache.org/licenses/LICENSE-2.0.html[Apache 2.0 license].
|
||||
|
||||
Reference in New Issue
Block a user