Appendices

Appendix A: Namespace reference

The <repositories /> Element

The <repositories /> element triggers the setup of the Spring Data repository infrastructure. The most important attribute is base-package, which defines the package to scan for Spring Data repository interfaces. See “[repositories.create-instances.spring]”. The following table describes the attributes of the <repositories /> element:spring-doc.cn

Table 6. Attributes
Name Description

base-packagespring-doc.cn

Defines the package to be scanned for repository interfaces that extend *Repository (the actual interface is determined by the specific Spring Data module) in auto-detection mode. All packages below the configured package are scanned, too. Wildcards are allowed.spring-doc.cn

repository-impl-postfixspring-doc.cn

Defines the postfix to autodetect custom repository implementations. Classes whose names end with the configured postfix are considered as candidates. Defaults to Impl.spring-doc.cn

query-lookup-strategyspring-doc.cn

Determines the strategy to be used to create finder queries. See “[repositories.query-methods.query-lookup-strategies]” for details. Defaults to create-if-not-found.spring-doc.cn

named-queries-locationspring-doc.cn

Defines the location to search for a Properties file containing externally defined queries.spring-doc.cn

consider-nested-repositoriesspring-doc.cn

Whether nested repository interface definitions should be considered. Defaults to false.spring-doc.cn

Appendix B: Populators namespace reference

The <populator /> element

The <populator /> element allows to populate the a data store via the Spring Data repository infrastructure.[1]spring-doc.cn

Table 7. Attributes
Name Description

locationsspring-doc.cn

Where to find the files to read the objects from the repository shall be populated with.spring-doc.cn

Appendix C: Repository query keywords

Supported query method subject keywords

The following table lists the subject keywords generally supported by the Spring Data repository query derivation mechanism to express the predicate. Consult the store-specific documentation for the exact list of supported keywords, because some keywords listed here might not be supported in a particular store.spring-doc.cn

Table 8. Query subject keywords
Keyword Description

find…By, read…By, get…By, query…By, search…By, stream…Byspring-doc.cn

General query method returning typically the repository type, a Collection or Streamable subtype or a result wrapper such as Page, GeoResults or any other store-specific result wrapper. Can be used as findBy…, findMyDomainTypeBy… or in combination with additional keywords.spring-doc.cn

exists…Byspring-doc.cn

Exists projection, returning typically a boolean result.spring-doc.cn

count…Byspring-doc.cn

Count projection returning a numeric result.spring-doc.cn

delete…By, remove…Byspring-doc.cn

Delete query method returning either no result (void) or the delete count.spring-doc.cn

…First<number>…, …Top<number>…spring-doc.cn

Limit the query results to the first <number> of results. This keyword can occur in any place of the subject between find (and the other keywords) and by.spring-doc.cn

…Distinct…spring-doc.cn

Use a distinct query to return only unique results. Consult the store-specific documentation whether that feature is supported. This keyword can occur in any place of the subject between find (and the other keywords) and by.spring-doc.cn

Supported query method predicate keywords and modifiers

The following table lists the predicate keywords generally supported by the Spring Data repository query derivation mechanism. However, consult the store-specific documentation for the exact list of supported keywords, because some keywords listed here might not be supported in a particular store.spring-doc.cn

Table 9. Query predicate keywords
Logical keyword Keyword expressions

ANDspring-doc.cn

Andspring-doc.cn

ORspring-doc.cn

Orspring-doc.cn

AFTERspring-doc.cn

After, IsAfterspring-doc.cn

BEFOREspring-doc.cn

Before, IsBeforespring-doc.cn

CONTAININGspring-doc.cn

Containing, IsContaining, Containsspring-doc.cn

BETWEENspring-doc.cn

Between, IsBetweenspring-doc.cn

ENDING_WITHspring-doc.cn

EndingWith, IsEndingWith, EndsWithspring-doc.cn

EXISTSspring-doc.cn

Existsspring-doc.cn

FALSEspring-doc.cn

False, IsFalsespring-doc.cn

GREATER_THANspring-doc.cn

GreaterThan, IsGreaterThanspring-doc.cn

GREATER_THAN_EQUALSspring-doc.cn

GreaterThanEqual, IsGreaterThanEqualspring-doc.cn

INspring-doc.cn

In, IsInspring-doc.cn

ISspring-doc.cn

Is, Equals, (or no keyword)spring-doc.cn

IS_EMPTYspring-doc.cn

IsEmpty, Emptyspring-doc.cn

IS_NOT_EMPTYspring-doc.cn

IsNotEmpty, NotEmptyspring-doc.cn

IS_NOT_NULLspring-doc.cn

NotNull, IsNotNullspring-doc.cn

IS_NULLspring-doc.cn

Null, IsNullspring-doc.cn

LESS_THANspring-doc.cn

LessThan, IsLessThanspring-doc.cn

LESS_THAN_EQUALspring-doc.cn

LessThanEqual, IsLessThanEqualspring-doc.cn

LIKEspring-doc.cn

Like, IsLikespring-doc.cn

NEARspring-doc.cn

Near, IsNearspring-doc.cn

NOTspring-doc.cn

Not, IsNotspring-doc.cn

NOT_INspring-doc.cn

NotIn, IsNotInspring-doc.cn

NOT_LIKEspring-doc.cn

NotLike, IsNotLikespring-doc.cn

REGEXspring-doc.cn

Regex, MatchesRegex, Matchesspring-doc.cn

STARTING_WITHspring-doc.cn

StartingWith, IsStartingWith, StartsWithspring-doc.cn

TRUEspring-doc.cn

True, IsTruespring-doc.cn

WITHINspring-doc.cn

Within, IsWithinspring-doc.cn

In addition to filter predicates, the following list of modifiers is supported:spring-doc.cn

Table 10. Query predicate modifier keywords
Keyword Description

IgnoreCase, IgnoringCasespring-doc.cn

Used with a predicate keyword for case-insensitive comparison.spring-doc.cn

AllIgnoreCase, AllIgnoringCasespring-doc.cn

Ignore case for all suitable properties. Used somewhere in the query method predicate.spring-doc.cn

OrderBy…spring-doc.cn

Specify a static sorting order followed by the property path and direction (e. g. OrderByFirstnameAscLastnameDesc).spring-doc.cn

Appendix D: Repository query return types

Supported Query Return Types

The following table lists the return types generally supported by Spring Data repositories. However, consult the store-specific documentation for the exact list of supported return types, because some types listed here might not be supported in a particular store.spring-doc.cn

Geospatial types (such as GeoResult, GeoResults, and GeoPage) are available only for data stores that support geospatial queries. Some store modules may define their own result wrapper types.
Table 11. Query return types
Return type Description

voidspring-doc.cn

Denotes no return value.spring-doc.cn

Primitivesspring-doc.cn

Java primitives.spring-doc.cn

Wrapper typesspring-doc.cn

Java wrapper types.spring-doc.cn

Tspring-doc.cn

A unique entity. Expects the query method to return one result at most. If no result is found, null is returned. More than one result triggers an IncorrectResultSizeDataAccessException.spring-doc.cn

Iterator<T>spring-doc.cn

An Iterator.spring-doc.cn

Collection<T>spring-doc.cn

A Collection.spring-doc.cn

List<T>spring-doc.cn

A List.spring-doc.cn

Optional<T>spring-doc.cn

A Java 8 or Guava Optional. Expects the query method to return one result at most. If no result is found, Optional.empty() or Optional.absent() is returned. More than one result triggers an IncorrectResultSizeDataAccessException.spring-doc.cn

Option<T>spring-doc.cn

Either a Scala or Vavr Option type. Semantically the same behavior as Java 8’s Optional, described earlier.spring-doc.cn

Stream<T>spring-doc.cn

A Java 8 Stream.spring-doc.cn

Streamable<T>spring-doc.cn

A convenience extension of Iterable that directy exposes methods to stream, map and filter results, concatenate them etc.spring-doc.cn

Types that implement Streamable and take a Streamable constructor or factory method argumentspring-doc.cn

Types that expose a constructor or ….of(…)/….valueOf(…) factory method taking a Streamable as argument. See [repositories.collections-and-iterables.streamable-wrapper] for details.spring-doc.cn

Vavr Seq, List, Map, Setspring-doc.cn

Vavr collection types. See [repositories.collections-and-iterables.vavr] for details.spring-doc.cn

Future<T>spring-doc.cn

A Future. Expects a method to be annotated with @Async and requires Spring’s asynchronous method execution capability to be enabled.spring-doc.cn

CompletableFuture<T>spring-doc.cn

A Java 8 CompletableFuture. Expects a method to be annotated with @Async and requires Spring’s asynchronous method execution capability to be enabled.spring-doc.cn

ListenableFuturespring-doc.cn

A org.springframework.util.concurrent.ListenableFuture. Expects a method to be annotated with @Async and requires Spring’s asynchronous method execution capability to be enabled.spring-doc.cn

Slice<T>spring-doc.cn

A sized chunk of data with an indication of whether there is more data available. Requires a Pageable method parameter.spring-doc.cn

Page<T>spring-doc.cn

A Slice with additional information, such as the total number of results. Requires a Pageable method parameter.spring-doc.cn

GeoResult<T>spring-doc.cn

A result entry with additional information, such as the distance to a reference location.spring-doc.cn

GeoResults<T>spring-doc.cn

A list of GeoResult<T> with additional information, such as the average distance to a reference location.spring-doc.cn

GeoPage<T>spring-doc.cn

A Page with GeoResult<T>, such as the average distance to a reference location.spring-doc.cn

Mono<T>spring-doc.cn

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.spring-doc.cn

Flux<T>spring-doc.cn

A Project Reactor Flux emitting zero, one, or many elements using reactive repositories. Queries returning Flux can emit also an infinite number of elements.spring-doc.cn

Single<T>spring-doc.cn

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.spring-doc.cn

Maybe<T>spring-doc.cn

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.spring-doc.cn

Flowable<T>spring-doc.cn

A RxJava Flowable emitting zero, one, or many elements using reactive repositories. Queries returning Flowable can emit also an infinite number of elements.spring-doc.cn