核心论点是,通过使用这些查询关键字,开发人员可以编写动态、类型安全和可读性强的查询,轻松地从存储库中检索和处理数据,从而提高生产力和代码可维护性。
Repository query keywords
Supported query method subject keywords
下表列出了 Spring Data 存储库查询派生机制通常支持的主体关键字,以表示谓词。有关受支持关键字的确切列表,请查阅特定存储区的文档,因为此处列出的某些关键字可能在特定存储区中不受支持。
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.
Keyword | Description |
---|---|
|
General query method returning typically the repository type, a |
|
Exists projection, returning typically a |
|
Count projection returning a numeric result. |
|
Delete query method returning either no result ( |
|
Limit the query results to the first |
|
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 |
Supported query method predicate keywords and modifiers
下表列出了 Spring Data 存储库查询派生机制通常支持的谓词关键字。但是,有关受支持关键字的确切列表,请查阅特定存储区的文档,因为此处列出的某些关键字可能在特定存储区中不受支持。
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.
Logical keyword | Keyword expressions |
---|---|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
除了过滤器谓词之外,还支持以下修改器列表:
In addition to filter predicates, the following list of modifiers is supported:
Keyword | Description |
---|---|
|
Used with a predicate keyword for case-insensitive comparison. |
|
Ignore case for all suitable properties. Used somewhere in the query method predicate. |
|
Specify a static sorting order followed by the property path and direction (e. g. |