Spring/Spring Data JPA
[Spring Data JPA] 3-7. Repository query keywords
noahkim_
2024. 8. 2. 10:20
1. Supported query method subject keywords
find…By read…By get…By query…By search…By stream…By |
General query method - can be used in combination with additional keywords Return type: the repository type - Collection, Streamable subtype, result wrapper (Page, GeoResults, store-specific) |
exists…By | Exists projection Return type: boolean |
count…By | Count projection Return type: boolean |
delete…By remove…By |
Delete query method Return type: void or delete count |
…First<numbe>… …Top<number>… |
Limit the query results to the first <number> of results. - can occur in any place of the subject (between find and by) |
…Distinct… | Use a distinct query to return only unique results. - Consult the store-specific documentation whether that feature is supported - can occur in any place of the subject (between find and by) |
2. Supported query method predicate keywords and modifiers
AND | And |
OR | Or |
AFTER | After, IsAfter |
BEFORE | Before, IsBefore |
CONTAINING | Containing, IsContaining, Contains |
BETWEEN | Between, IsBetween |
ENDING_WITH | EndingWith, IsEndingWith, EndsWith |
EXISTS | Exists |
FALSE | False, IsFalse |
GREATER_THAN | GreaterThan, IsGreaterThan |
GREATER_THAN_EQUALS | GreaterThanEqual, IsGreaterThanEqual |
IN | In, IsIn |
IS | Is, Equals, (or no keyword) |
IS_EMPTY | IsEmpty, Empty |
IS_NOT_EMPTY | IsNotEmpty, NotEmpty |
IS_NOT_NULL | NotNull, IsNotNull |
IS_NULL | Null, IsNull |
LESS_THAN | LessThan, IsLessThan |
LESS_THAN_EQUAL | LessThanEqual, IsLessThanEqual |
LIKE | Like, IsLike |
NEAR | Near, IsNear |
NOT | Not, IsNot |
NOT_IN | NotIn, IsNotIn |
NOT_LIKE | NotLike, IsNotLike |
REGEX | Regex, MatchesRegex, Matches |
STARTING_WITH | StartingWith, IsStartingWith, StartsWith |
TRUE | True, IsTrue |
WITHIN | Within, IsWithin |
출처