|
1 |
| -image:https://spring.io/badges/spring-data-r2dbc/snapshot.svg["Spring Data R2DBC", link="https://spring.io/projects/spring-data-r2dbc#learn"] |
| 1 | += Spring Data R2DBC |
2 | 2 |
|
3 |
| -= Spring Data R2DBC image:https://jenkins.spring.io/buildStatus/icon?job=spring-data-r2dbc%2Fmain&subject=Build[link=https://jenkins.spring.io/view/SpringData/job/spring-data-r2dbc/] https://gitter.im/spring-projects/spring-data[image:https://badges.gitter.im/spring-projects/spring-data.svg[Gitter]] |
4 |
| - |
5 |
| -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 data access technologies. *Spring Data R2DBC* offers the popular Repository abstraction based on https://r2dbc.io[R2DBC]. |
6 |
| - |
7 |
| -R2DBC is the abbreviation for https://github.com/r2dbc/[Reactive Relational Database Connectivity], an incubator to integrate relational databases using a reactive driver. |
8 |
| - |
9 |
| -== This is NOT an ORM |
10 |
| - |
11 |
| -Spring Data R2DBC aims at being conceptually easy. In order to achieve this it does NOT offer caching, lazy loading, write behind or many other features of ORM frameworks. This makes Spring Data R2DBC a simple, limited, opinionated object mapper. |
12 |
| - |
13 |
| -== Features |
14 |
| - |
15 |
| -* Spring configuration support using Java based `@Configuration` classes. |
16 |
| -* Annotation based mapping metadata. |
17 |
| -* Automatic implementation of Repository interfaces including support. |
18 |
| -* Support for Reactive Transactions |
19 |
| -* Schema and data initialization utilities. |
20 |
| - |
21 |
| -== Code of Conduct |
22 |
| - |
23 |
| -This project is governed by the https://github.com/spring-projects/.github/blob/e3cc2ff230d8f1dca06535aa6b5a4a23815861d4/CODE_OF_CONDUCT.md[Spring Code of Conduct]. By participating, you are expected to uphold this code of conduct. Please report unacceptable behavior to [email protected]. |
24 |
| - |
25 |
| -== Getting Started |
26 |
| - |
27 |
| -Here is a quick teaser of an application using Spring Data Repositories in Java: |
28 |
| - |
29 |
| -[source,java] |
30 |
| ----- |
31 |
| -public interface PersonRepository extends ReactiveCrudRepository<Person, Long> { |
32 |
| -
|
33 |
| - @Query("SELECT * FROM person WHERE lastname = :lastname") |
34 |
| - Flux<Person> findByLastname(String lastname); |
35 |
| -
|
36 |
| - @Query("SELECT * FROM person WHERE firstname LIKE :firstname") |
37 |
| - Flux<Person> findByFirstnameLike(String firstname); |
38 |
| -} |
39 |
| -
|
40 |
| -@Service |
41 |
| -public class MyService { |
42 |
| -
|
43 |
| - private final PersonRepository repository; |
44 |
| -
|
45 |
| - public MyService(PersonRepository repository) { |
46 |
| - this.repository = repository; |
47 |
| - } |
48 |
| -
|
49 |
| - public void doWork() { |
50 |
| -
|
51 |
| - repository.deleteAll().block(); |
52 |
| -
|
53 |
| - Person person = new Person(); |
54 |
| - person.setFirstname("Mark"); |
55 |
| - person.setLastname("Paluch"); |
56 |
| - repository.save(person).block(); |
57 |
| -
|
58 |
| - Flux<Person> lastNameResults = repository.findByLastname("Paluch"); |
59 |
| - Flux<Person> firstNameResults = repository.findByFirstnameLike("M%"); |
60 |
| - } |
61 |
| -} |
62 |
| -
|
63 |
| -@Configuration |
64 |
| -@EnableR2dbcRepositories |
65 |
| -class ApplicationConfig extends AbstractR2dbcConfiguration { |
66 |
| -
|
67 |
| - @Bean |
68 |
| - public ConnectionFactory connectionFactory() { |
69 |
| - return ConnectionFactories.get("r2dbc:h2:mem:///test?options=DB_CLOSE_DELAY=-1;DB_CLOSE_ON_EXIT=FALSE"); |
70 |
| - } |
71 |
| -} |
72 |
| ----- |
73 |
| - |
74 |
| -=== Maven configuration |
75 |
| - |
76 |
| -Add the Maven dependency: |
77 |
| - |
78 |
| -[source,xml] |
79 |
| ----- |
80 |
| -<dependency> |
81 |
| - <groupId>org.springframework.data</groupId> |
82 |
| - <artifactId>spring-data-r2dbc</artifactId> |
83 |
| - <version>${version}</version> |
84 |
| -</dependency> |
85 |
| ----- |
86 |
| - |
87 |
| -If you'd rather like the latest snapshots of the upcoming major version, use our Maven snapshot repository and declare the appropriate dependency version. |
88 |
| - |
89 |
| -[source,xml] |
90 |
| ----- |
91 |
| -<dependency> |
92 |
| - <groupId>org.springframework.data</groupId> |
93 |
| - <artifactId>spring-data-r2dbc</artifactId> |
94 |
| - <version>${version}-SNAPSHOT</version> |
95 |
| -</dependency> |
96 |
| -
|
97 |
| -<repository> |
98 |
| - <id>spring-libs-snapshot</id> |
99 |
| - <name>Spring Snapshot Repository</name> |
100 |
| - <url>https://repo.spring.io/libs-snapshot</url> |
101 |
| -</repository> |
102 |
| ----- |
103 |
| - |
104 |
| -== Getting Help |
105 |
| - |
106 |
| -Having trouble with Spring Data? We’d love to help! |
107 |
| - |
108 |
| -* Check the |
109 |
| -https://docs.spring.io/spring-data/r2dbc/docs/1.0.x/reference/html/#reference[reference documentation], and https://docs.spring.io/spring-data/r2dbc/docs/1.0.x/api/[Javadocs]. |
110 |
| -* 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. |
111 |
| -If you are just starting out with Spring, try one of the https://spring.io/guides[guides]. |
112 |
| -* If you are upgrading, check out the https://docs.spring.io/spring-data/r2dbc/docs/current/changelog.txt[changelog] for "`new and noteworthy`" features. |
113 |
| -* Ask a question - we monitor https://stackoverflow.com[stackoverflow.com] for questions tagged with https://stackoverflow.com/tags/spring-data-r2dbc[`spring-data-r2dbc`]. |
114 |
| -* Report bugs with Spring Data R2DBC at https://github.com/spring-projects/spring-data-r2dbc/issues[github.com/spring-projects/spring-data-r2dbc/issues]. |
115 |
| - |
116 |
| -== Reporting Issues |
117 |
| - |
118 |
| -Spring Data uses GitHub as issue tracking system to record bugs and feature requests. If you want to raise an issue, please follow the recommendations below: |
119 |
| - |
120 |
| -* Before you log a bug, please search the |
121 |
| -https://github.com/spring-projects/spring-data-r2dbc/issues[issue tracker] to see if someone has already reported the problem. |
122 |
| -* If the issue does not already exist, https://github.com/spring-projects/spring-data-r2dbc/issues/new[create a new issue]. |
123 |
| -* 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. |
124 |
| -* If you need to paste code, or include a stack trace use Markdown +++```+++ escapes before and after your text. |
125 |
| -* 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. |
126 |
| - |
127 |
| -== Building from Source |
128 |
| - |
129 |
| -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]. |
130 |
| -You also need JDK 1.8. |
131 |
| - |
132 |
| -[source,bash] |
133 |
| ----- |
134 |
| - $ ./mvnw clean install |
135 |
| ----- |
136 |
| - |
137 |
| -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]. |
138 |
| - |
139 |
| -_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 non-trivial change._ |
140 |
| - |
141 |
| -=== Building reference documentation |
142 |
| - |
143 |
| -Building the documentation builds also the project without running tests. |
144 |
| - |
145 |
| -[source,bash] |
146 |
| ----- |
147 |
| - $ ./mvnw clean install -Pdistribute |
148 |
| ----- |
149 |
| - |
150 |
| -The generated documentation is available from `target/site/reference/html/index.html`. |
151 |
| - |
152 |
| -== Examples |
153 |
| - |
154 |
| -* https://github.com/spring-projects/spring-data-examples/[Spring Data Examples] contains example projects that explain specific features in more detail. |
| 3 | +This project is merged as of version 3.0 in the https://github.com/spring-projects/spring-data-relational[Spring Data Relational] repository. |
155 | 4 |
|
156 | 5 | == License
|
157 | 6 |
|
|
0 commit comments