DATAKV-93 - Added README and reference documentation.

Original pull request: #3.
This commit is contained in:
Christoph Strobl
2014-12-02 10:35:00 +01:00
committed by Oliver Gierke
parent bc88cb48ac
commit 680d32fff8
4 changed files with 129 additions and 10 deletions

75
readme.md Normal file
View File

@@ -0,0 +1,75 @@
# Spring Data Key Value #
The primary goal of the [Spring Data](http://projects.spring.io/spring-data) project is to make it easier to build Spring-powered applications that use data access technologies. This module provides infrastructure components to build repository abstractions for stores dealing with Key/Value pairs and ships with a default `java.util.Map` based implementation.
## Features ##
* Infrastructure for building repositories on top of key/value implementations.
* Dynamic SpEL query generation from query method names.
* Possibility to integrate custom repository code.
## Quick Start ##
Download the jar though Maven:
```xml
<dependency>
<groupId>org.springframework.data</groupId>
<artifactId>spring-data-key-value</artifactId>
<version>0.1.0.BUILD-SNAPSHOT</version>
</dependency>
```
The `ConcurrentHashMap` based default configuration looks like this:
```java
@Configuration
@EnableMapRepositories("com.acme.repositories")
class AppConfig {
}
```
**Note** it is possible to change the used `java.util.Map` implementation via `@EnableMapRepositories(mapType=... .class)`.
Create the domain type and use `@KeySpace` to explicitly group values into one region. By default the types class name is used.
```java
@KeySpace("user")
class User {
@Id String uuid;
String firstname;
}
```
Create a repository interface in `com.acme.repositories`:
```java
public interface UserRepository extends CrudRepository<User, String> {
List<String> findByLastname(String lastname);
}
```
## QueryDSL ##
To use Querydsl with Spring Data KeyValue repositories `com.mysema.querydsl:querydsl-collections:3.6.0` (or better) needs to be present.
Just add `QueryDslPredicateExecutor` to the repository definition and use `com.mysema.query.types.Predicate` to define the query.
## Tips ##
To have the maximum performance we encourage you to use the latest Spring 4.1.x or better release with compiled SpEL expressions enabled.
```
-Dspring.expression.compiler.mode=IMMEDIATE
```
## Contributing to Spring Data Key Value##
Here are some ways for you to get involved in the community:
* Get involved with the Spring community by helping out on [stackoverflow](http://stackoverflow.com/questions/tagged/spring-data-keyvalue) by responding to questions and joining the debate.
* Create [JIRA](https://jira.springsource.org/browse/DATAKV) 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 [forks of this repository](http://help.github.com/forking/). 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 [subscribing](http://spring.io/blog) to spring.io.
Before we accept a non-trivial patch or pull request we will need you to sign the [contributor's agreement](https://support.springsource.com/spring_committer_signup). 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. Active contributors might be asked to join the core team, and given the ability to merge pull requests.

View File

@@ -0,0 +1,36 @@
= Spring Data Key Value - Reference Documentation
Oliver Gierke; Thomas Darimont; Christoph Strobl;
:revnumber: {version}
:revdate: {localdate}
:toc:
:toc-placement!:
:spring-data-commons-docs: https://raw.githubusercontent.com/spring-projects/spring-data-commons/master/src/main/asciidoc
:spring-framework-docs: http://docs.spring.io/spring-framework/docs/current/spring-framework-reference/html
(C) 2008-2014 The original authors.
NOTE: 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.
toc::[]
include::preface.adoc[]
:leveloffset: +1
include::{spring-data-commons-docs}/repositories.adoc[]
:leveloffset: -1
[[reference]]
= Reference Documentation
:leveloffset: +1
include::key-value-repositories.adoc[]
:leveloffset: -1
[[appendix]]
= Appendix
:numbered!:
:leveloffset: +1
include::{spring-data-commons-docs}/repository-namespace-reference.adoc[]
include::{spring-data-commons-docs}/repository-populator-namespace-reference.adoc[]
include::{spring-data-commons-docs}/repository-query-keywords-reference.adoc[]
:leveloffset: -1

View File

@@ -97,7 +97,7 @@ template.findAllOf(User.class); <2>
Query execution is managed by the `QueryEngine`. As mentioned before it is possible to instruct the `KeyValueAdapter` to use an implementation specific `QueryEngine` that allows access to native functionality.
When used without further customization queries are be executed using a `SpELQueryEngine`.
NOTE: For performance reasons, we highly recommend to have at least Spring 4.1.2 or better to make use of link:{spring-framework-docs}/expressions.html#expressions-spel-compilation[compiled SpEL Expressions].
NOTE: For performance reasons, we highly recommend to have at least Spring 4.1.2 or better to make use of link:{spring-framework-docs}/expressions.html#expressions-spel-compilation[compiled SpEL Expressions]. Please use the `-Dspring.expression.compiler.mode=IMMEDIATE` switch to turn it on.
[source, java]
----
@@ -122,22 +122,17 @@ List<Person> targaryens = template.find(query, Person.class);
WARNING: Please note that you need to have getters/setters present to sort using SpEL.
[[key-value.repositories]]
== Key Value Repositories
[[key-value.repositories.map]]
== Map Repositories
KeyValue repositories reside on top of the `KeyValaueTemplate`. Using the default `SpelQueryCreator` allows deriving query and sort expressions from the given methodname.
Map repositories reside on top of the `KeyValaueTemplate`. Using the default `SpelQueryCreator` allows deriving query and sort expressions from the given methodname.
[source, java]
----
@Configuration
@EnableKeyValueRepositories
@EnableMapRepositories
class KeyValueConfig {
@Bean
public KeyValueOperations keyValueTemplate() {
return new KeyValueTemplate(new MapKeyValueAdapter());
}
}
interface PersonRepository implements CrudRepository<Person, String> {

View File

@@ -0,0 +1,13 @@
[[preface]]
= Preface
[[project]]
[preface]
== Project metadata
* Version control - http://github.com/spring-projects/spring-data-keyvalue
* Bugtracker - https://jira.spring.io/browse/DATAKV
* Release repository - https://repo.spring.io/libs-release
* Milestone repository - https://repo.spring.io/libs-milestone
* Snapshot repository - https://repo.spring.io/libs-snapshot