You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
Copy file name to clipboardExpand all lines: modules/ROOT/pages/jpa/query-methods.adoc
+6-6Lines changed: 6 additions & 6 deletions
Display the source diff
Display the rich diff
Original file line number
Diff line number
Diff line change
@@ -12,11 +12,11 @@ Derived queries with the predicates `IsStartingWith`, `StartingWith`, `StartsWit
12
12
`IsNotContaining`, `NotContaining`, `NotContains`, `IsContaining`, `Containing`, `Contains` the respective arguments for these queries will get sanitized.
13
13
This means if the arguments actually contain characters recognized by `LIKE` as wildcards these will get escaped so they match only as literals.
14
14
The escape character used can be configured by setting the `escapeCharacter` of the `@EnableJpaRepositories` annotation.
15
-
Compare with <<jpa.query.spel-expressions>>.
15
+
Compare with xref:jpa/query-methods.adoc#jpa.query.spel-expressions[Using SpEL Expressions].
16
16
17
17
[[jpa.query-methods.declared-queries]]
18
18
=== Declared Queries
19
-
Although getting a query derived from the method name is quite convenient, one might face the situation in which either the method name parser does not support the keyword one wants to use or the method name would get unnecessarily ugly. So you can either use JPA named queries through a naming convention (see <<jpa.query-methods.named-queries>> for more information) or rather annotate your query method with `@Query` (see <<jpa.query-methods.at-query>> for details).
19
+
Although getting a query derived from the method name is quite convenient, one might face the situation in which either the method name parser does not support the keyword one wants to use or the method name would get unnecessarily ugly. So you can either use JPA named queries through a naming convention (see xref:jpa/query-methods.adoc#jpa.query-methods.named-queries[Using JPA Named Queries] for more information) or rather annotate your query method with `@Query` (see xref:jpa/query-methods.adoc#jpa.query-methods.at-query[Using `@Query`] for details).
20
20
21
21
[[jpa.query-methods.query-creation]]
22
22
== Query Creation
@@ -313,7 +313,7 @@ Sorting can be done by either providing a `PageRequest` or by using `Sort` direc
313
313
314
314
NOTE: Using any non-referenceable path expression leads to an `Exception`.
315
315
316
-
However, using `Sort` together with <<jpa.query-methods.at-query, `@Query`>> lets you sneak in non-path-checked `Order` instances containing functions within the `ORDER BY` clause. This is possible because the `Order` is appended to the given query string. By default, Spring Data JPA rejects any `Order` instance containing function calls, but you can use `JpaSort.unsafe` to add potentially unsafe ordering.
316
+
However, using `Sort` together with xref:jpa/query-methods.adoc#jpa.query-methods.at-query[`@Query`] lets you sneak in non-path-checked `Order` instances containing functions within the `ORDER BY` clause. This is possible because the `Order` is appended to the given query string. By default, Spring Data JPA rejects any `Order` instance containing function calls, but you can use `JpaSort.unsafe` to add potentially unsafe ordering.
317
317
318
318
The following example uses `Sort` and `JpaSort`, including an unsafe option on `JpaSort`:
319
319
@@ -359,7 +359,7 @@ This method avoids https://use-the-index-luke.com/no-offset[the shortcomings of
359
359
360
360
Read more on <<repositories.scrolling.guidance,which method to use best>> for your particular arrangement.
361
361
362
-
You can use the Scroll API with query methods, <<query-by-example.running,Query-by-Example>>, and <<core.extensions.querydsl,Querydsl>>.
362
+
You can use the Scroll API with query methods, xref:query-by-example.adoc[Query-by-Example], and <<core.extensions.querydsl,Querydsl>>.
363
363
364
364
NOTE: Scrolling with String-based query methods is not yet supported.
365
365
Scrolling is also not supported using stored `@Procedure` query methods.
@@ -506,12 +506,12 @@ Spring Data JPA offers many ways to build queries.
506
506
But sometimes, your query may simply be too complicated for the techniques offered.
507
507
In that situation, consider:
508
508
509
-
* If you haven't already, simply write the query yourself using <<jpa.query-methods.at-query,`@Query`>>.
509
+
* If you haven't already, simply write the query yourself using xref:jpa/query-methods.adoc#jpa.query-methods.at-query[`@Query`].
510
510
* If that doesn't fit your needs, consider implementing a <<repositories.custom-implementations,custom implementation>>. This lets you register a method in your repository while leaving the implementation completely up to you. This gives you the ability to:
511
511
** Talk directly to the `EntityManager` (writing pure HQL/JPQL/EQL/native SQL or using the *Criteria API*)
512
512
** Leverage Spring Framework's `JdbcTemplate` (native SQL)
513
513
** Use another 3rd-party database toolkit.
514
-
* Another option is putting your query inside the database and then using either Spring Data JPA's <<jpa.stored-procedures,`@StoredProcedure` annotation>> or if it's a database function using the <<jpa.query-methods.at-query,`@Query` annotation>> and invoking it with a `CALL`.
514
+
* Another option is putting your query inside the database and then using either Spring Data JPA's xref:jpa/stored-procedures.adoc[`@StoredProcedure` annotation] or if it's a database function using the xref:jpa/query-methods.adoc#jpa.query-methods.at-query[`@Query` annotation] and invoking it with a `CALL`.
515
515
516
516
These tactics may be most effective when you need maximum control of your query, while still letting Spring Data JPA provide resource management.
0 commit comments