This version is still in development and is not considered stable yet. For the latest stable version, please use Spring Data Redis 3.4.0!spring-doc.cn

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 1. 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

Reserved methods

The following table lists reserved methods that use predefined functionality (as defined in CrudRepository). These methods are directly invoked on the backing (store-specific) implementation of the repository proxy. See also “Defining Query Methods”.spring-doc.cn

Table 2. Reserved methods

deleteAllById(Iterable<ID> identifiers)spring-doc.cn

deleteById(ID identifier)spring-doc.cn

existsById(ID identifier)spring-doc.cn

findAllById(Iterable<ID> identifiers)spring-doc.cn

findById(ID identifier)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 3. 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 4. 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