DATACMNS-1291 - Polishing.

Typo fixes, align Enable…Repositories annotation wording, document reactive return types.

Original pull request: #281.
This commit is contained in:
Mark Paluch
2018-04-12 11:08:05 +02:00
parent 4da35a8f32
commit 0dfcfe4186
3 changed files with 16 additions and 14 deletions

View File

@@ -5,13 +5,13 @@ Oliver Gierke; Thomas Darimont; Christoph Strobl; Mark Pollack; Thomas Risberg;
:linkcss:
:doctype: book
:docinfo: shared
:toc: left
:toc:
:toclevels: 4
:source-highlighter: prettify
:icons: font
(C) 2008-2017 The original authors.
(C) 2008-2018 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.

View File

@@ -161,7 +161,7 @@ class Config {}
+
The JPA namespace is used in this example. If you use the repository abstraction for any other store, you need to change this to the appropriate namespace declaration of your store module. In other words, you should exchange `jpa` in favor of, for example, `mongodb`.
+
Also, note that the JavaConfig variant does not configure a package explicitly, because the package of the annotated class is used by default. To customize the package to scan, use one of the `basePackage…` attributes of the data-store-specific repository's `@Enable`-annotation.
Also, note that the JavaConfig variant does not configure a package explicitly, because the package of the annotated class is used by default. To customize the package to scan, use one of the `basePackage…` attributes of the data-store-specific repository's `@Enable${store}Repositories`-annotation.
. Inject the repository instance and use it, as shown in the following example:
+
@@ -234,7 +234,7 @@ Besides that, Spring Data supports returning the following wrapper types on quer
* `com.google.common.base.Optional`
* `scala.Option`
* `io.vavr.control.Option`
* `javaslang.control.Option` (deprecated as `javaslang` is deprecated)
* `javaslang.control.Option` (deprecated as Javaslang is deprecated)
Alternatively, query methods can choose not to use a wrapper type at all.
The absence of a query result is then indicated by returning `null`.
@@ -265,7 +265,7 @@ package com.acme;
====
Once non-null defaulting is in place, repository query method invocations get validated at runtime for nullability constraints.
if a query execution result violates the defined constraint, an exception is thrown. This happens when the method would return `null` but is declared as non-nullable (the default with the annotation defined on the package the repository resides in).
If a query execution result violates the defined constraint, an exception is thrown. This happens when the method would return `null` but is declared as non-nullable (the default with the annotation defined on the package the repository resides in).
If you want to opt-in to nullable results again, selectively use `@Nullable` on individual methods.
Using the result wrapper types mentioned at the start of this section continues to work as expected: An empty result is translated into the value that represents absence.
@@ -573,7 +573,7 @@ NOTE: Limiting the results in combination with dynamic sorting by using a `Sort`
[[repositories.query-streaming]]
=== Streaming query results
The results of query methods can be processed incrementally by using a Java 8 `Stream<T>` as return type. Instead of wrapping the query results in a `Stream` data store, specific methods are used to perform the streaming, as shown in the following example:
The results of query methods can be processed incrementally by using a Java 8 `Stream<T>` as return type. Instead of wrapping the query results in a `Stream` data store-specific methods are used to perform the streaming, as shown in the following example:
.Stream the result of a query with Java 8 `Stream<T>`
====
@@ -604,7 +604,7 @@ NOTE: Not all Spring Data modules currently support `Stream<T>` as a return type
[[repositories.query-async]]
=== Async query results
Repository queries can be run asynchronously by using link:{spring-framework-docs}/integration.html#scheduling[Spring's asynchronous method execution capability]. This means the method returns immediately upon invocation while the actual query execution occurs in a task that has been submitted to a Spring `TaskExecutor`. The following example shows a number of asynchronous queries:
Repository queries can be run asynchronously by using link:{spring-framework-docs}/integration.html#scheduling[Spring's asynchronous method execution capability]. This means the method returns immediately upon invocation while the actual query execution occurs in a task that has been submitted to a Spring `TaskExecutor`. Asynchronous query execution is different from reactive query execution and should not be mixed. Refer to store-specific documentation for more details on reactive support. The following example shows a number of asynchronous queries:
====
[source, java]
@@ -779,11 +779,11 @@ class HumanRepositoryImpl implements HumanRepository {
}
}
interface EmployeeRepository {
interface ContactRepository {
void someEmployeeMethod(User user);
void someContactMethod(User user);
User anotherEmployeeMethod(User user);
User anotherContactMethod(User user);
}
class ContactRepositoryImpl implements ContactRepository {
@@ -799,8 +799,6 @@ class ContactRepositoryImpl implements ContactRepository {
----
====
// TODO Did you mean to have EmployeeRepositoryImpl after EmployeeRepository? ContactRepositoryImpl comes as a surprise.
The following example shows the interface for a custom repository that extends `CrudRepository`:
.Changes to your repository interface
@@ -946,7 +944,7 @@ class MyRepositoryImpl<T, ID extends Serializable>
CAUTION: The class needs to have a constructor of the super class which the store-specific repository factory implementation uses. If the repository base class has multiple constructors, override the one taking an `EntityInformation` plus a store specific infrastructure object (such as an `EntityManager` or a template class).
The final step is to make the Spring Data infrastructure aware of the customized repository base class. In Java configuration, you can do so by using the `repositoryBaseClass` attribute of the `@EnableRepositories` annotation, as shown in the following example:
The final step is to make the Spring Data infrastructure aware of the customized repository base class. In Java configuration, you can do so by using the `repositoryBaseClass` attribute of the `@Enable${store}Repositories` annotation, as shown in the following example:
.Configuring a custom repository base class using JavaConfig
====
@@ -1041,7 +1039,6 @@ To make use of Querydsl support, extend `QuerydslPredicateExecutor` on your repo
[source, java]
----
interface UserRepository extends CrudRepository<User, Long>, QuerydslPredicateExecutor<User> {
}
----
====

View File

@@ -29,4 +29,9 @@ NOTE: Geospatial types (such as `GeoResult`, `GeoResults`, and `GeoPage`) are av
|`GeoResult<T>`|A result entry with additional information, such as the distance to a reference location.
|`GeoResults<T>`|A list of `GeoResult<T>` with additional information, such as the average distance to a reference location.
|`GeoPage<T>`|A `Page` with `GeoResult<T>`, such as the average distance to a reference location.
|`Mono<T>`|A Project Reactor `Mono` emitting zero or one element using reactive repositories. Expects the query method to return one result at most. If no result is found, `Mono.empty()` is returned. More than one result triggers an `IncorrectResultSizeDataAccessException`.
|`Flux<T>`|A Project Reactor `Flux` emitting zero, one, or many elements using reactive repositories. Queries returning `Flux` can emit also an infinite number of elements.
|`Single<T>`|A RxJava `Single` emitting a single element using reactive repositories. Expects the query method to return one result at most. If no result is found, `Mono.empty()` is returned. More than one result triggers an `IncorrectResultSizeDataAccessException`.
|`Maybe<T>`|A RxJava `Maybe` emitting zero or one element using reactive repositories. Expects the query method to return one result at most. If no result is found, `Mono.empty()` is returned. More than one result triggers an `IncorrectResultSizeDataAccessException`.
|`Flowable<T>`|A RxJava `Flowable` emitting zero, one, or many elements using reactive repositories. Queries returning `Flowable` can emit also an infinite number of elements.
|===============