@@ -32,49 +32,49 @@ Here is a quick teaser of an application using Spring Data JDBC Repositories in
3232----
3333interface PersonRepository extends CrudRepository<Person, Long> {
3434
35- @Query("SELECT * FROM person WHERE lastname = :lastname")
36- List<Person> findByLastname(String lastname);
35+ @Query("SELECT * FROM person WHERE lastname = :lastname")
36+ List<Person> findByLastname(String lastname);
3737
38- @Query("SELECT * FROM person WHERE firstname LIKE :firstname")
39- List<Person> findByFirstnameLike(String firstname);
38+ @Query("SELECT * FROM person WHERE firstname LIKE :firstname")
39+ List<Person> findByFirstnameLike(String firstname);
4040}
4141
4242@Service
4343class MyService {
4444
45- private final PersonRepository repository;
45+ private final PersonRepository repository;
4646
47- public MyService(PersonRepository repository) {
48- this.repository = repository;
49- }
47+ public MyService(PersonRepository repository) {
48+ this.repository = repository;
49+ }
5050
51- public void doWork() {
51+ public void doWork() {
5252
53- repository.deleteAll();
53+ repository.deleteAll();
5454
55- Person person = new Person();
56- person.setFirstname("Jens");
57- person.setLastname("Schauder");
58- repository.save(person);
55+ Person person = new Person();
56+ person.setFirstname("Jens");
57+ person.setLastname("Schauder");
58+ repository.save(person);
5959
60- List<Person> lastNameResults = repository.findByLastname("Schauder");
61- List<Person> firstNameResults = repository.findByFirstnameLike("Je%");
62- }
60+ List<Person> lastNameResults = repository.findByLastname("Schauder");
61+ List<Person> firstNameResults = repository.findByFirstnameLike("Je%");
62+ }
6363}
6464
6565@Configuration
6666@EnableJdbcRepositories
6767class ApplicationConfig extends AbstractJdbcConfiguration {
6868
69- @Bean
70- public DataSource dataSource() {
71- return …;
72- }
69+ @Bean
70+ public DataSource dataSource() {
71+ return …;
72+ }
7373
74- @Bean
75- public NamedParameterJdbcTemplate namedParameterJdbcTemplate(DataSource dataSource) {
76- return new NamedParameterJdbcTemplate(dataSource);
77- }
74+ @Bean
75+ public NamedParameterJdbcTemplate namedParameterJdbcTemplate(DataSource dataSource) {
76+ return new NamedParameterJdbcTemplate(dataSource);
77+ }
7878}
7979----
8080
@@ -85,9 +85,9 @@ Add the Maven dependency:
8585[source,xml]
8686----
8787<dependency>
88- <groupId>org.springframework.data</groupId>
89- <artifactId>spring-data-jdbc</artifactId>
90- <version>${version}</version>
88+ <groupId>org.springframework.data</groupId>
89+ <artifactId>spring-data-jdbc</artifactId>
90+ <version>${version}</version>
9191</dependency>
9292----
9393
@@ -96,15 +96,15 @@ If you'd rather like the latest snapshots of the upcoming major version, use our
9696[source,xml]
9797----
9898<dependency>
99- <groupId>org.springframework.data</groupId>
100- <artifactId>spring-data-jdbc</artifactId>
101- <version>${version}-SNAPSHOT</version>
99+ <groupId>org.springframework.data</groupId>
100+ <artifactId>spring-data-jdbc</artifactId>
101+ <version>${version}-SNAPSHOT</version>
102102</dependency>
103103
104104<repository>
105- <id>spring-snapshot</id>
106- <name>Spring Snapshot Repository</name>
107- <url>https://repo.spring.io/snapshot</url>
105+ <id>spring-snapshot</id>
106+ <name>Spring Snapshot Repository</name>
107+ <url>https://repo.spring.io/snapshot</url>
108108</repository>
109109----
110110
@@ -116,46 +116,46 @@ Here is a quick teaser of an application using Spring Data R2DBC Repositories in
116116----
117117interface PersonRepository extends ReactiveCrudRepository<Person, Long> {
118118
119- @Query("SELECT * FROM person WHERE lastname = :lastname")
120- Flux<Person> findByLastname(String lastname);
119+ @Query("SELECT * FROM person WHERE lastname = :lastname")
120+ Flux<Person> findByLastname(String lastname);
121121
122- @Query("SELECT * FROM person WHERE firstname LIKE :firstname")
123- Flux<Person> findByFirstnameLike(String firstname);
122+ @Query("SELECT * FROM person WHERE firstname LIKE :firstname")
123+ Flux<Person> findByFirstnameLike(String firstname);
124124}
125125
126126@Service
127127class MyService {
128128
129- private final PersonRepository repository;
129+ private final PersonRepository repository;
130130
131- public MyService(PersonRepository repository) {
132- this.repository = repository;
133- }
131+ public MyService(PersonRepository repository) {
132+ this.repository = repository;
133+ }
134134
135- public Flux<Person> doWork() {
135+ public Flux<Person> doWork() {
136136
137- Person person = new Person();
138- person.setFirstname("Jens");
139- person.setLastname("Schauder");
140- repository.save(person);
137+ Person person = new Person();
138+ person.setFirstname("Jens");
139+ person.setLastname("Schauder");
140+ repository.save(person);
141141
142- Mono<Void> deleteAll = repository.deleteAll();
142+ Mono<Void> deleteAll = repository.deleteAll();
143143
144- Flux<Person> lastNameResults = repository.findByLastname("Schauder");
145- Flux<Person> firstNameResults = repository.findByFirstnameLike("Je%");
144+ Flux<Person> lastNameResults = repository.findByLastname("Schauder");
145+ Flux<Person> firstNameResults = repository.findByFirstnameLike("Je%");
146146
147- return deleteAll.thenMany(lastNameResults.concatWith(firstNameResults));
148- }
147+ return deleteAll.thenMany(lastNameResults.concatWith(firstNameResults));
148+ }
149149}
150150
151151@Configuration
152152@EnableR2dbcRepositories
153153class ApplicationConfig extends AbstractR2dbcConfiguration {
154154
155- @Bean
156- public ConnectionFactory connectionFactory() {
157- return ConnectionFactories.get("r2dbc:<driver>://<host>:<port>/<database>");
158- }
155+ @Bean
156+ public ConnectionFactory connectionFactory() {
157+ return ConnectionFactories.get("r2dbc:<driver>://<host>:<port>/<database>");
158+ }
159159
160160}
161161----
@@ -167,9 +167,9 @@ Add the Maven dependency:
167167[source,xml]
168168----
169169<dependency>
170- <groupId>org.springframework.data</groupId>
171- <artifactId>spring-data-r2dbc</artifactId>
172- <version>${version}</version>
170+ <groupId>org.springframework.data</groupId>
171+ <artifactId>spring-data-r2dbc</artifactId>
172+ <version>${version}</version>
173173</dependency>
174174----
175175
@@ -178,15 +178,15 @@ If you'd rather like the latest snapshots of the upcoming major version, use our
178178[source,xml]
179179----
180180<dependency>
181- <groupId>org.springframework.data</groupId>
182- <artifactId>spring-data-r2dbc</artifactId>
183- <version>${version}-SNAPSHOT</version>
181+ <groupId>org.springframework.data</groupId>
182+ <artifactId>spring-data-r2dbc</artifactId>
183+ <version>${version}-SNAPSHOT</version>
184184</dependency>
185185
186186<repository>
187- <id>spring-libs-snapshot</id>
188- <name>Spring Snapshot Repository</name>
189- <url>https://repo.spring.io/snapshot</url>
187+ <id>spring-libs-snapshot</id>
188+ <name>Spring Snapshot Repository</name>
189+ <url>https://repo.spring.io/snapshot</url>
190190</repository>
191191----
192192
0 commit comments