Skip to content

Repository query 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.

Table 1. Query subject keywords

KeywordDescription
find…By, read…By, get…By, query…By, search…By, stream…ByGeneral 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.
exists…ByExists projection, returning typically a boolean result.
count…ByCount projection returning a numeric result.
delete…By, remove…ByDelete query method returning either no result (void) or the delete count.
…First<number>…, …Top<number>…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.
…Distinct…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.

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

Table 2. Reserved methods

deleteAllById(Iterable<ID> identifiers)
deleteById(ID identifier)
existsById(ID identifier)
findAllById(Iterable<ID> identifiers)
findById(ID identifier)

Supported query method predicate keywords and modifiers

Section titled “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.

Table 3. Query predicate keywords

Logical keywordKeyword expressions
ANDAnd
OROr
AFTERAfter, IsAfter
BEFOREBefore, IsBefore
CONTAININGContaining, IsContaining, Contains
BETWEENBetween, IsBetween
ENDING_WITHEndingWith, IsEndingWith, EndsWith
EXISTSExists
FALSEFalse, IsFalse
GREATER_THANGreaterThan, IsGreaterThan
GREATER_THAN_EQUALSGreaterThanEqual, IsGreaterThanEqual
INIn, IsIn
ISIs, Equals, (or no keyword)
IS_EMPTYIsEmpty, Empty
IS_NOT_EMPTYIsNotEmpty, NotEmpty
IS_NOT_NULLNotNull, IsNotNull
IS_NULLNull, IsNull
LESS_THANLessThan, IsLessThan
LESS_THAN_EQUALLessThanEqual, IsLessThanEqual
LIKELike, IsLike
NEARNear, IsNear
NOTNot, IsNot
NOT_INNotIn, IsNotIn
NOT_LIKENotLike, IsNotLike
REGEXRegex, MatchesRegex, Matches
STARTING_WITHStartingWith, IsStartingWith, StartsWith
TRUETrue, IsTrue
WITHINWithin, IsWithin

In addition to filter predicates, the following list of modifiers is supported:

Table 4. Query predicate modifier keywords

KeywordDescription
IgnoreCase, IgnoringCaseUsed with a predicate keyword for case-insensitive comparison.
AllIgnoreCase, AllIgnoringCaseIgnore case for all suitable properties. Used somewhere in the query method predicate.
OrderBy…Specify a static sorting order followed by the property path and direction (e. g. OrderByFirstnameAscLastnameDesc).