Browse Source

Fix indentation in code examples.

Fixes the indentation to 4 characters in all code examples in *.adoc files.

Original pull request #1948
pull/1954/head
Jens Schauder 1 year ago
parent
commit
e651a565a1
No known key found for this signature in database
GPG Key ID: 74F6C554AE971567
  1. 130
      README.adoc
  2. 8
      src/main/antora/modules/ROOT/pages/jdbc/auditing.adoc
  3. 22
      src/main/antora/modules/ROOT/pages/jdbc/getting-started.adoc
  4. 8
      src/main/antora/modules/ROOT/pages/jdbc/mybatis.adoc
  5. 34
      src/main/antora/modules/ROOT/pages/jdbc/query-methods.adoc
  6. 10
      src/main/antora/modules/ROOT/pages/jdbc/schema-support.adoc
  7. 49
      src/main/antora/modules/ROOT/pages/jdbc/transactions.adoc
  8. 8
      src/main/antora/modules/ROOT/pages/r2dbc/auditing.adoc
  9. 8
      src/main/antora/modules/ROOT/pages/r2dbc/entity-persistence.adoc
  10. 62
      src/main/antora/modules/ROOT/pages/r2dbc/getting-started.adoc
  11. 52
      src/main/antora/modules/ROOT/pages/r2dbc/mapping.adoc
  12. 28
      src/main/antora/modules/ROOT/pages/r2dbc/query-methods.adoc
  13. 20
      src/main/antora/modules/ROOT/pages/r2dbc/repositories.adoc

130
README.adoc

@ -32,49 +32,49 @@ Here is a quick teaser of an application using Spring Data JDBC Repositories in @@ -32,49 +32,49 @@ Here is a quick teaser of an application using Spring Data JDBC Repositories in
----
interface PersonRepository extends CrudRepository<Person, Long> {
@Query("SELECT * FROM person WHERE lastname = :lastname")
List<Person> findByLastname(String lastname);
@Query("SELECT * FROM person WHERE lastname = :lastname")
List<Person> findByLastname(String lastname);
@Query("SELECT * FROM person WHERE firstname LIKE :firstname")
List<Person> findByFirstnameLike(String firstname);
@Query("SELECT * FROM person WHERE firstname LIKE :firstname")
List<Person> findByFirstnameLike(String firstname);
}
@Service
class MyService {
private final PersonRepository repository;
private final PersonRepository repository;
public MyService(PersonRepository repository) {
this.repository = repository;
}
public MyService(PersonRepository repository) {
this.repository = repository;
}
public void doWork() {
public void doWork() {
repository.deleteAll();
repository.deleteAll();
Person person = new Person();
person.setFirstname("Jens");
person.setLastname("Schauder");
repository.save(person);
Person person = new Person();
person.setFirstname("Jens");
person.setLastname("Schauder");
repository.save(person);
List<Person> lastNameResults = repository.findByLastname("Schauder");
List<Person> firstNameResults = repository.findByFirstnameLike("Je%");
}
List<Person> lastNameResults = repository.findByLastname("Schauder");
List<Person> firstNameResults = repository.findByFirstnameLike("Je%");
}
}
@Configuration
@EnableJdbcRepositories
class ApplicationConfig extends AbstractJdbcConfiguration {
@Bean
public DataSource dataSource() {
return …;
}
@Bean
public DataSource dataSource() {
return …;
}
@Bean
public NamedParameterJdbcTemplate namedParameterJdbcTemplate(DataSource dataSource) {
return new NamedParameterJdbcTemplate(dataSource);
}
@Bean
public NamedParameterJdbcTemplate namedParameterJdbcTemplate(DataSource dataSource) {
return new NamedParameterJdbcTemplate(dataSource);
}
}
----
@ -85,9 +85,9 @@ Add the Maven dependency: @@ -85,9 +85,9 @@ Add the Maven dependency:
[source,xml]
----
<dependency>
<groupId>org.springframework.data</groupId>
<artifactId>spring-data-jdbc</artifactId>
<version>${version}</version>
<groupId>org.springframework.data</groupId>
<artifactId>spring-data-jdbc</artifactId>
<version>${version}</version>
</dependency>
----
@ -96,15 +96,15 @@ If you'd rather like the latest snapshots of the upcoming major version, use our @@ -96,15 +96,15 @@ If you'd rather like the latest snapshots of the upcoming major version, use our
[source,xml]
----
<dependency>
<groupId>org.springframework.data</groupId>
<artifactId>spring-data-jdbc</artifactId>
<version>${version}-SNAPSHOT</version>
<groupId>org.springframework.data</groupId>
<artifactId>spring-data-jdbc</artifactId>
<version>${version}-SNAPSHOT</version>
</dependency>
<repository>
<id>spring-snapshot</id>
<name>Spring Snapshot Repository</name>
<url>https://repo.spring.io/snapshot</url>
<id>spring-snapshot</id>
<name>Spring Snapshot Repository</name>
<url>https://repo.spring.io/snapshot</url>
</repository>
----
@ -116,46 +116,46 @@ Here is a quick teaser of an application using Spring Data R2DBC Repositories in @@ -116,46 +116,46 @@ Here is a quick teaser of an application using Spring Data R2DBC Repositories in
----
interface PersonRepository extends ReactiveCrudRepository<Person, Long> {
@Query("SELECT * FROM person WHERE lastname = :lastname")
Flux<Person> findByLastname(String lastname);
@Query("SELECT * FROM person WHERE lastname = :lastname")
Flux<Person> findByLastname(String lastname);
@Query("SELECT * FROM person WHERE firstname LIKE :firstname")
Flux<Person> findByFirstnameLike(String firstname);
@Query("SELECT * FROM person WHERE firstname LIKE :firstname")
Flux<Person> findByFirstnameLike(String firstname);
}
@Service
class MyService {
private final PersonRepository repository;
private final PersonRepository repository;
public MyService(PersonRepository repository) {
this.repository = repository;
}
public MyService(PersonRepository repository) {
this.repository = repository;
}
public Flux<Person> doWork() {
public Flux<Person> doWork() {
Person person = new Person();
person.setFirstname("Jens");
person.setLastname("Schauder");
repository.save(person);
Person person = new Person();
person.setFirstname("Jens");
person.setLastname("Schauder");
repository.save(person);
Mono<Void> deleteAll = repository.deleteAll();
Mono<Void> deleteAll = repository.deleteAll();
Flux<Person> lastNameResults = repository.findByLastname("Schauder");
Flux<Person> firstNameResults = repository.findByFirstnameLike("Je%");
Flux<Person> lastNameResults = repository.findByLastname("Schauder");
Flux<Person> firstNameResults = repository.findByFirstnameLike("Je%");
return deleteAll.thenMany(lastNameResults.concatWith(firstNameResults));
}
return deleteAll.thenMany(lastNameResults.concatWith(firstNameResults));
}
}
@Configuration
@EnableR2dbcRepositories
class ApplicationConfig extends AbstractR2dbcConfiguration {
@Bean
public ConnectionFactory connectionFactory() {
return ConnectionFactories.get("r2dbc:<driver>://<host>:<port>/<database>");
}
@Bean
public ConnectionFactory connectionFactory() {
return ConnectionFactories.get("r2dbc:<driver>://<host>:<port>/<database>");
}
}
----
@ -167,9 +167,9 @@ Add the Maven dependency: @@ -167,9 +167,9 @@ Add the Maven dependency:
[source,xml]
----
<dependency>
<groupId>org.springframework.data</groupId>
<artifactId>spring-data-r2dbc</artifactId>
<version>${version}</version>
<groupId>org.springframework.data</groupId>
<artifactId>spring-data-r2dbc</artifactId>
<version>${version}</version>
</dependency>
----
@ -178,15 +178,15 @@ If you'd rather like the latest snapshots of the upcoming major version, use our @@ -178,15 +178,15 @@ If you'd rather like the latest snapshots of the upcoming major version, use our
[source,xml]
----
<dependency>
<groupId>org.springframework.data</groupId>
<artifactId>spring-data-r2dbc</artifactId>
<version>${version}-SNAPSHOT</version>
<groupId>org.springframework.data</groupId>
<artifactId>spring-data-r2dbc</artifactId>
<version>${version}-SNAPSHOT</version>
</dependency>
<repository>
<id>spring-libs-snapshot</id>
<name>Spring Snapshot Repository</name>
<url>https://repo.spring.io/snapshot</url>
<id>spring-libs-snapshot</id>
<name>Spring Snapshot Repository</name>
<url>https://repo.spring.io/snapshot</url>
</repository>
----

8
src/main/antora/modules/ROOT/pages/jdbc/auditing.adoc

@ -11,10 +11,10 @@ In order to activate auditing, add `@EnableJdbcAuditing` to your configuration, @@ -11,10 +11,10 @@ In order to activate auditing, add `@EnableJdbcAuditing` to your configuration,
@EnableJdbcAuditing
class Config {
@Bean
AuditorAware<AuditableUser> auditorProvider() {
return new AuditorAwareImpl();
}
@Bean
AuditorAware<AuditableUser> auditorProvider() {
return new AuditorAwareImpl();
}
}
----

22
src/main/antora/modules/ROOT/pages/jdbc/getting-started.adoc

@ -39,13 +39,13 @@ Then enter a project and a package name, such as `org.spring.jdbc.example`. @@ -39,13 +39,13 @@ Then enter a project and a package name, such as `org.spring.jdbc.example`.
----
<dependencies>
<!-- other dependency elements omitted -->
<!-- other dependency elements omitted -->
<dependency>
<groupId>org.springframework.data</groupId>
<artifactId>spring-data-jdbc</artifactId>
<version>{version}</version>
</dependency>
<dependency>
<groupId>org.springframework.data</groupId>
<artifactId>spring-data-jdbc</artifactId>
<version>{version}</version>
</dependency>
</dependencies>
----
@ -62,11 +62,11 @@ Then enter a project and a package name, such as `org.spring.jdbc.example`. @@ -62,11 +62,11 @@ Then enter a project and a package name, such as `org.spring.jdbc.example`.
[source,xml]
----
<repositories>
<repository>
<id>spring-milestone</id>
<name>Spring Maven MILESTONE Repository</name>
<url>https://repo.spring.io/milestone</url>
</repository>
<repository>
<id>spring-milestone</id>
<name>Spring Maven MILESTONE Repository</name>
<url>https://repo.spring.io/milestone</url>
</repository>
</repositories>
----

8
src/main/antora/modules/ROOT/pages/jdbc/mybatis.adoc

@ -16,10 +16,10 @@ The easiest way to properly plug MyBatis into Spring Data JDBC is by importing ` @@ -16,10 +16,10 @@ The easiest way to properly plug MyBatis into Spring Data JDBC is by importing `
@Import(MyBatisJdbcConfiguration.class)
class Application {
@Bean
SqlSessionFactoryBean sqlSessionFactoryBean() {
// Configure MyBatis here
}
@Bean
SqlSessionFactoryBean sqlSessionFactoryBean() {
// Configure MyBatis here
}
}
----

34
src/main/antora/modules/ROOT/pages/jdbc/query-methods.adoc

@ -11,25 +11,25 @@ Defining such a query is a matter of declaring a method on the repository interf @@ -11,25 +11,25 @@ Defining such a query is a matter of declaring a method on the repository interf
----
interface PersonRepository extends PagingAndSortingRepository<Person, String> {
List<Person> findByFirstname(String firstname); <1>
List<Person> findByFirstname(String firstname); <1>
List<Person> findByFirstnameOrderByLastname(String firstname, Pageable pageable); <2>
List<Person> findByFirstnameOrderByLastname(String firstname, Pageable pageable); <2>
Slice<Person> findByLastname(String lastname, Pageable pageable); <3>
Slice<Person> findByLastname(String lastname, Pageable pageable); <3>
Page<Person> findByLastname(String lastname, Pageable pageable); <4>
Page<Person> findByLastname(String lastname, Pageable pageable); <4>
Person findByFirstnameAndLastname(String firstname, String lastname); <5>
Person findByFirstnameAndLastname(String firstname, String lastname); <5>
Person findFirstByLastname(String lastname); <6>
Person findFirstByLastname(String lastname); <6>
@Query("SELECT * FROM person WHERE lastname = :lastname")
List<Person> findByLastname(String lastname); <7>
@Query("SELECT * FROM person WHERE lastname = :lastname")
Stream<Person> streamByLastname(String lastname); <8>
@Query("SELECT * FROM person WHERE lastname = :lastname")
List<Person> findByLastname(String lastname); <7>
@Query("SELECT * FROM person WHERE lastname = :lastname")
Stream<Person> streamByLastname(String lastname); <8>
@Query("SELECT * FROM person WHERE username = :#{ principal?.username }")
Person findActiveUser(); <9>
@Query("SELECT * FROM person WHERE username = :#{ principal?.username }")
Person findActiveUser(); <9>
}
----
<1> The method shows a query for all people with the given `firstname`.
@ -156,8 +156,8 @@ The following example shows how to use `@Query` to declare a query method: @@ -156,8 +156,8 @@ The following example shows how to use `@Query` to declare a query method:
----
interface UserRepository extends CrudRepository<User, Long> {
@Query("select firstName, lastName from User u where u.emailAddress = :email")
User findByEmailAddress(@Param("email") String email);
@Query("select firstName, lastName from User u where u.emailAddress = :email")
User findByEmailAddress(@Param("email") String email);
}
----
@ -252,9 +252,9 @@ The following example shows how to register `DefaultQueryMappingConfiguration`: @@ -252,9 +252,9 @@ The following example shows how to register `DefaultQueryMappingConfiguration`:
----
@Bean
QueryMappingConfiguration rowMappers() {
return new DefaultQueryMappingConfiguration()
.register(Person.class, new PersonRowMapper())
.register(Address.class, new AddressRowMapper());
return new DefaultQueryMappingConfiguration()
.register(Person.class, new PersonRowMapper())
.register(Address.class, new AddressRowMapper());
}
----

10
src/main/antora/modules/ROOT/pages/jdbc/schema-support.adoc

@ -11,11 +11,11 @@ Consider the following domain entity: @@ -11,11 +11,11 @@ Consider the following domain entity:
----
@Table
class Person {
@Id long id;
String firstName;
String lastName;
LocalDate birthday;
boolean active;
@Id long id;
String firstName;
String lastName;
LocalDate birthday;
boolean active;
}
----

49
src/main/antora/modules/ROOT/pages/jdbc/transactions.adoc

@ -12,11 +12,11 @@ If you need to tweak transaction configuration for one of the methods declared i @@ -12,11 +12,11 @@ If you need to tweak transaction configuration for one of the methods declared i
----
interface UserRepository extends CrudRepository<User, Long> {
@Override
@Transactional(timeout = 10)
List<User> findAll();
@Override
@Transactional(timeout = 10)
List<User> findAll();
// Further query method declarations
// Further query method declarations
}
----
@ -32,23 +32,24 @@ The following example shows how to create such a facade: @@ -32,23 +32,24 @@ The following example shows how to create such a facade:
@Service
public class UserManagementImpl implements UserManagement {
private final UserRepository userRepository;
private final RoleRepository roleRepository;
private final UserRepository userRepository;
private final RoleRepository roleRepository;
UserManagementImpl(UserRepository userRepository,
RoleRepository roleRepository) {
this.userRepository = userRepository;
this.roleRepository = roleRepository;
}
UserManagementImpl(UserRepository userRepository,
RoleRepository roleRepository) {
this.userRepository = userRepository;
this.roleRepository = roleRepository;
}
@Transactional
public void addRoleToAllUsers(String roleName) {
@Transactional
public void addRoleToAllUsers(String roleName) {
Role role = roleRepository.findByName(roleName);
Role role = roleRepository.findByName(roleName);
for (User user : userRepository.findAll()) {
user.addRole(role);
userRepository.save(user);
for (User user : userRepository.findAll()) {
user.addRole(role);
userRepository.save(user);
}
}
}
----
@ -69,12 +70,12 @@ To let your query methods be transactional, use `@Transactional` at the reposito @@ -69,12 +70,12 @@ To let your query methods be transactional, use `@Transactional` at the reposito
@Transactional(readOnly = true)
interface UserRepository extends CrudRepository<User, Long> {
List<User> findByLastname(String lastname);
List<User> findByLastname(String lastname);
@Modifying
@Transactional
@Query("delete from User u where u.active = false")
void deleteInactiveUsers();
@Modifying
@Transactional
@Query("delete from User u where u.active = false")
void deleteInactiveUsers();
}
----
@ -105,8 +106,8 @@ In that cases both modes are equivalent of `PESSIMISTIC_WRITE`. @@ -105,8 +106,8 @@ In that cases both modes are equivalent of `PESSIMISTIC_WRITE`.
----
interface UserRepository extends CrudRepository<User, Long> {
@Lock(LockMode.PESSIMISTIC_READ)
List<User> findByLastname(String lastname);
@Lock(LockMode.PESSIMISTIC_READ)
List<User> findByLastname(String lastname);
}
----

8
src/main/antora/modules/ROOT/pages/r2dbc/auditing.adoc

@ -10,10 +10,10 @@ Since Spring Data R2DBC 1.2, auditing can be enabled by annotating a configurati @@ -10,10 +10,10 @@ Since Spring Data R2DBC 1.2, auditing can be enabled by annotating a configurati
@EnableR2dbcAuditing
class Config {
@Bean
public ReactiveAuditorAware<AuditableUser> myAuditorProvider() {
return new AuditorAwareImpl();
}
@Bean
public ReactiveAuditorAware<AuditableUser> myAuditorProvider() {
return new AuditorAwareImpl();
}
}
----

8
src/main/antora/modules/ROOT/pages/r2dbc/entity-persistence.adoc

@ -189,10 +189,10 @@ include::partial$optimistic-locking.adoc[] @@ -189,10 +189,10 @@ include::partial$optimistic-locking.adoc[]
@Table
class Person {
@Id Long id;
String firstname;
String lastname;
@Version Long version;
@Id Long id;
String firstname;
String lastname;
@Version Long version;
}
R2dbcEntityTemplate template = …;

62
src/main/antora/modules/ROOT/pages/r2dbc/getting-started.adoc

@ -41,20 +41,20 @@ Then enter a project and a package name, such as `org.spring.r2dbc.example`. @@ -41,20 +41,20 @@ Then enter a project and a package name, such as `org.spring.r2dbc.example`.
----
<dependencies>
<!-- other dependency elements omitted -->
<!-- other dependency elements omitted -->
<dependency>
<groupId>org.springframework.data</groupId>
<artifactId>spring-data-r2dbc</artifactId>
<version>{version}</version>
</dependency>
<dependency>
<groupId>org.springframework.data</groupId>
<artifactId>spring-data-r2dbc</artifactId>
<version>{version}</version>
</dependency>
<!-- a R2DBC driver -->
<dependency>
<groupId>io.r2dbc</groupId>
<artifactId>r2dbc-h2</artifactId>
<version>x.y.z</version>
</dependency>
<!-- a R2DBC driver -->
<dependency>
<groupId>io.r2dbc</groupId>
<artifactId>r2dbc-h2</artifactId>
<version>x.y.z</version>
</dependency>
</dependencies>
----
@ -71,11 +71,11 @@ Then enter a project and a package name, such as `org.spring.r2dbc.example`. @@ -71,11 +71,11 @@ Then enter a project and a package name, such as `org.spring.r2dbc.example`.
[source,xml]
----
<repositories>
<repository>
<id>spring-milestone</id>
<name>Spring Maven MILESTONE Repository</name>
<url>https://repo.spring.io/milestone</url>
</repository>
<repository>
<id>spring-milestone</id>
<name>Spring Maven MILESTONE Repository</name>
<url>https://repo.spring.io/milestone</url>
</repository>
</repositories>
----
@ -100,10 +100,11 @@ Next, you need to create a table structure in your database, as follows: @@ -100,10 +100,11 @@ Next, you need to create a table structure in your database, as follows:
[source,sql]
----
CREATE TABLE person
(id VARCHAR(255) PRIMARY KEY,
name VARCHAR(255),
age INT);
CREATE TABLE person(
id VARCHAR(255) PRIMARY KEY,
name VARCHAR(255),
age INT
);
----
You also need a main application to run, as follows:
@ -117,10 +118,11 @@ When you run the main program, the preceding examples produce output similar to @@ -117,10 +118,11 @@ When you run the main program, the preceding examples produce output similar to
[source]
----
2018-11-28 10:47:03,893 DEBUG amework.core.r2dbc.DefaultDatabaseClient: 310 - Executing SQL statement [CREATE TABLE person
(id VARCHAR(255) PRIMARY KEY,
name VARCHAR(255),
age INT)]
2018-11-28 10:47:03,893 DEBUG amework.core.r2dbc.DefaultDatabaseClient: 310 - Executing SQL statement [CREATE TABLE person(
id VARCHAR(255) PRIMARY KEY,
name VARCHAR(255),
age INT
)]
2018-11-28 10:47:04,074 DEBUG amework.core.r2dbc.DefaultDatabaseClient: 908 - Executing SQL statement [INSERT INTO person (id, name, age) VALUES($1, $2, $3)]
2018-11-28 10:47:04,092 DEBUG amework.core.r2dbc.DefaultDatabaseClient: 575 - Executing SQL statement [SELECT id, name, age FROM person]
2018-11-28 10:47:04,436 INFO org.spring.r2dbc.example.R2dbcApp: 43 - Person [id='joe', name='Joe', age=34]
@ -155,11 +157,11 @@ The following example shows an example of using Java-based bean metadata to regi @@ -155,11 +157,11 @@ The following example shows an example of using Java-based bean metadata to regi
@Configuration
public class ApplicationConfiguration extends AbstractR2dbcConfiguration {
@Override
@Bean
public ConnectionFactory connectionFactory() {
return …
}
@Override
@Bean
public ConnectionFactory connectionFactory() {
return …
}
}
----

52
src/main/antora/modules/ROOT/pages/r2dbc/mapping.adoc

@ -62,16 +62,16 @@ See xref:r2dbc/getting-started.adoc#r2dbc.dialects[R2DBC Drivers] for how to con @@ -62,16 +62,16 @@ See xref:r2dbc/getting-started.adoc#r2dbc.dialects[R2DBC Drivers] for how to con
@Configuration
public class MyAppConfig extends AbstractR2dbcConfiguration {
public ConnectionFactory connectionFactory() {
return ConnectionFactories.get("r2dbc:…");
}
public ConnectionFactory connectionFactory() {
return ConnectionFactories.get("r2dbc:…");
}
// the following are optional
// the following are optional
@Override
protected List<Object> getCustomConverters() {
return List.of(new PersonReadConverter(), new PersonWriteConverter());
}
@Override
protected List<Object> getCustomConverters() {
return List.of(new PersonReadConverter(), new PersonWriteConverter());
}
}
----
@ -100,14 +100,14 @@ package com.mycompany.domain; @@ -100,14 +100,14 @@ package com.mycompany.domain;
@Table
public class Person {
@Id
private Long id;
@Id
private Long id;
private Integer ssn;
private Integer ssn;
private String firstName;
private String firstName;
private String lastName;
private String lastName;
}
----
@ -199,13 +199,13 @@ The following example of a Spring Converter implementation converts from a `Row` @@ -199,13 +199,13 @@ The following example of a Spring Converter implementation converts from a `Row`
[source,java]
----
@ReadingConverter
public class PersonReadConverter implements Converter<Row, Person> {
public class PersonReadConverter implements Converter<Row, Person> {
public Person convert(Row source) {
Person p = new Person(source.get("id", String.class),source.get("name", String.class));
p.setAge(source.get("age", Integer.class));
return p;
}
public Person convert(Row source) {
Person p = new Person(source.get("id", String.class),source.get("name", String.class));
p.setAge(source.get("age", Integer.class));
return p;
}
}
----
@ -222,13 +222,13 @@ The following example converts from a `Person` to a `OutboundRow`: @@ -222,13 +222,13 @@ The following example converts from a `Person` to a `OutboundRow`:
@WritingConverter
public class PersonWriteConverter implements Converter<Person, OutboundRow> {
public OutboundRow convert(Person source) {
OutboundRow row = new OutboundRow();
row.put("id", Parameter.from(source.getId()));
row.put("name", Parameter.from(source.getFirstName()));
row.put("age", Parameter.from(source.getAge()));
return row;
}
public OutboundRow convert(Person source) {
OutboundRow row = new OutboundRow();
row.put("id", Parameter.from(source.getId()));
row.put("name", Parameter.from(source.getFirstName()));
row.put("age", Parameter.from(source.getAge()));
return row;
}
}
----

28
src/main/antora/modules/ROOT/pages/r2dbc/query-methods.adoc

@ -10,21 +10,21 @@ Defining such a query is a matter of declaring a method on the repository interf @@ -10,21 +10,21 @@ Defining such a query is a matter of declaring a method on the repository interf
----
interface ReactivePersonRepository extends ReactiveSortingRepository<Person, Long> {
Flux<Person> findByFirstname(String firstname); <1>
Flux<Person> findByFirstname(String firstname); <1>
Flux<Person> findByFirstname(Publisher<String> firstname); <2>
Flux<Person> findByFirstname(Publisher<String> firstname); <2>
Flux<Person> findByFirstnameOrderByLastname(String firstname, Pageable pageable); <3>
Flux<Person> findByFirstnameOrderByLastname(String firstname, Pageable pageable); <3>
Mono<Person> findByFirstnameAndLastname(String firstname, String lastname); <4>
Mono<Person> findByFirstnameAndLastname(String firstname, String lastname); <4>
Mono<Person> findFirstByLastname(String lastname); <5>
Mono<Person> findFirstByLastname(String lastname); <5>
@Query("SELECT * FROM person WHERE lastname = :lastname")
Flux<Person> findByLastname(String lastname); <6>
@Query("SELECT * FROM person WHERE lastname = :lastname")
Flux<Person> findByLastname(String lastname); <6>
@Query("SELECT firstname, lastname FROM person WHERE lastname = $1")
Mono<Person> findFirstByLastname(String lastname); <7>
@Query("SELECT firstname, lastname FROM person WHERE lastname = $1")
Mono<Person> findFirstByLastname(String lastname); <7>
}
----
@ -147,11 +147,11 @@ Using keywords from the preceding table can be used in conjunction with `delete @@ -147,11 +147,11 @@ Using keywords from the preceding table can be used in conjunction with `delete
----
interface ReactivePersonRepository extends ReactiveSortingRepository<Person, String> {
Mono<Integer> deleteByLastname(String lastname); <1>
Mono<Integer> deleteByLastname(String lastname); <1>
Mono<Void> deletePersonByLastname(String lastname); <2>
Mono<Void> deletePersonByLastname(String lastname); <2>
Mono<Boolean> deletePersonByLastname(String lastname); <3>
Mono<Boolean> deletePersonByLastname(String lastname); <3>
}
----
@ -192,8 +192,8 @@ The following example shows how to use `@Query` to declare a query method: @@ -192,8 +192,8 @@ The following example shows how to use `@Query` to declare a query method:
----
interface UserRepository extends ReactiveCrudRepository<User, Long> {
@Query("select firstName, lastName from User u where u.emailAddress = :email")
Flux<User> findByEmailAddress(@Param("email") String email);
@Query("select firstName, lastName from User u where u.emailAddress = :email")
Flux<User> findByEmailAddress(@Param("email") String email);
}
----

20
src/main/antora/modules/ROOT/pages/r2dbc/repositories.adoc

@ -18,12 +18,12 @@ Consider the following `Person` class: @@ -18,12 +18,12 @@ Consider the following `Person` class:
----
public class Person {
@Id
private Long id;
private String firstname;
private String lastname;
@Id
private Long id;
private String firstname;
private String lastname;
// … getters and setters omitted
// … getters and setters omitted
}
----
@ -34,7 +34,7 @@ The following example shows a repository interface for the preceding `Person` cl @@ -34,7 +34,7 @@ The following example shows a repository interface for the preceding `Person` cl
----
public interface PersonRepository extends ReactiveCrudRepository<Person, Long> {
// additional custom query methods go here
// additional custom query methods go here
}
----
@ -49,10 +49,10 @@ The following example shows how to use Java configuration for a repository: @@ -49,10 +49,10 @@ The following example shows how to use Java configuration for a repository:
@EnableR2dbcRepositories
class ApplicationConfig extends AbstractR2dbcConfiguration {
@Override
public ConnectionFactory connectionFactory() {
return …
}
@Override
public ConnectionFactory connectionFactory() {
return …
}
}
----

Loading…
Cancel
Save