1. Supported Query Return Types
| void | no return value |
| Primitives | Java primitives |
| Wrapper types | Java wrapper types |
| T | A unique entity - Expects the query method to return one result at most. - If no result is found, null is returned. |
| Iterator<T> | An Iterator |
| Collection<T> | A Collection |
| List<T> | A List |
| Optional<T> | A Java 8 or Guava Optional - Expects return one result at most. (IncorrectResultSizeDataAccessException) - If no result is found, Optional.empty() or Optional.absent() is returned. |
| Option<T> | Either a Scala or Vavr Option type - Semantically the same behavior as Java 8’s Optional, described earlier. |
| Stream<T> | A Java 8 Stream |
| Streamable<T> | A convenience extension of Iterable - directly exposes methods to stream (map, filter results, concatenate them etc) |
| Streamable impl constructor (Streamable) |
constructor factory method taking a Streamable as argument (….of(…)/….valueOf(…)) |
| Vavr Seq, List, Map, Set | Vavr collection types |
| Future<T> | A Future - Expects a method to be annotated with @Async - Requires Spring’s asynchronous method execution capability to be enabled |
| CompletableFuture<T> | A Java 8 CompletableFuture - Expects a method to be annotated with @Async - Requires Spring’s asynchronous method execution capability to be enabled |
| Slice<T> | A sized chunk of data with an indication of whether there is more data available. - Requires a Pageable method parameter |
| Page<T> | A Slice with additional information, such as the total number of results. - Requires a Pageable method parameter |
| Window<T> | A Window of results obtained from a scroll query. - Provides ScrollPosition to issue the next scroll query. - Requires a ScrollPosition method parameter. |
| GeoResult<T> | A result entry with additional information (distance) |
| GeoResults<T> | A list of GeoResult<T> with additional information (the average distance) |
| GeoPage<T> | A Page with GeoResult<T> (the average distance) |
| Mono<T> | A Project Reactor Mono emitting zero or one element using reactive repositories. - Expects return one result at most. (IncorrectResultSizeDataAccessException) - If no result is found, Mono.empty() is returned. |
| Flux<T> | A Project Reactor Flux emitting zero, one, or many using reactive repositories. - can emit also an infinite number of elements |
| Single<T> | A RxJava Single emitting a single element using reactive repositories. - Expects return one result at most. (IncorrectResultSizeDataAccessException) - If no result is found, Mono.empty() is returned. |
| Maybe<T> | A RxJava Maybe emitting zero or one element using reactive repositories. - Expects return one result at most. (IncorrectResultSizeDataAccessException) - If no result is found, Mono.empty() is returned. |
| Flowable<T> | A RxJava Flowable emitting zero, one, or many elements using reactive repositories. - can emit also an infinite number of elements. |
IncorrectResultSizeDataAccessException
- More than one result triggers
출처
'Spring > Spring Data JPA' 카테고리의 다른 글
| [Spring Data JPA] 3-1. Defining Query Methods (2) (0) | 2024.08.02 |
|---|---|
| [Spring Data JPA] 3-1. Defining Query Methods (1) (1) | 2024.08.02 |
| [Spring Data JPA] 3-7. Repository query keywords (1) | 2024.08.02 |
| [자바 ORM 표준 JPA 프로그래밍] 8. 프록시와 연관관계 관리 (0) | 2023.12.28 |
| [자바 ORM 표준 JPA 프로그래밍] 7. 고급 매핑 (2) | 2023.12.28 |