From 4bc23f25462aeee104c075f27f18919c1c33fe0a Mon Sep 17 00:00:00 2001 From: "Greg L. Turnquist" Date: Wed, 7 Jun 2023 10:54:55 -0500 Subject: [PATCH 1/2] Create branch. --- pom.xml | 2 +- spring-data-envers/pom.xml | 4 ++-- spring-data-jpa-distribution/pom.xml | 2 +- spring-data-jpa/pom.xml | 4 ++-- 4 files changed, 6 insertions(+), 6 deletions(-) diff --git a/pom.xml b/pom.xml index 91916af9b9..b8d0f26702 100644 --- a/pom.xml +++ b/pom.xml @@ -5,7 +5,7 @@ org.springframework.data spring-data-jpa-parent - 3.2.0-SNAPSHOT + 3.2.0-gh-3005-SNAPSHOT pom Spring Data JPA Parent diff --git a/spring-data-envers/pom.xml b/spring-data-envers/pom.xml index 0c3d16ef85..1ef1b62ca2 100755 --- a/spring-data-envers/pom.xml +++ b/spring-data-envers/pom.xml @@ -5,12 +5,12 @@ org.springframework.data spring-data-envers - 3.2.0-SNAPSHOT + 3.2.0-gh-3005-SNAPSHOT org.springframework.data spring-data-jpa-parent - 3.2.0-SNAPSHOT + 3.2.0-gh-3005-SNAPSHOT ../pom.xml diff --git a/spring-data-jpa-distribution/pom.xml b/spring-data-jpa-distribution/pom.xml index 991cd8cbf0..38b93f7829 100644 --- a/spring-data-jpa-distribution/pom.xml +++ b/spring-data-jpa-distribution/pom.xml @@ -14,7 +14,7 @@ org.springframework.data spring-data-jpa-parent - 3.2.0-SNAPSHOT + 3.2.0-gh-3005-SNAPSHOT ../pom.xml diff --git a/spring-data-jpa/pom.xml b/spring-data-jpa/pom.xml index 7145881fb0..0dac6de83c 100644 --- a/spring-data-jpa/pom.xml +++ b/spring-data-jpa/pom.xml @@ -6,7 +6,7 @@ org.springframework.data spring-data-jpa - 3.2.0-SNAPSHOT + 3.2.0-gh-3005-SNAPSHOT Spring Data JPA Spring Data module for JPA repositories. @@ -15,7 +15,7 @@ org.springframework.data spring-data-jpa-parent - 3.2.0-SNAPSHOT + 3.2.0-gh-3005-SNAPSHOT ../pom.xml From 56436e33a99465a3e19f64040e0600c1400bad05 Mon Sep 17 00:00:00 2001 From: "Greg L. Turnquist" Date: Wed, 7 Jun 2023 10:55:04 -0500 Subject: [PATCH 2/2] Add section to reference docs highlighting other possibilities. Give users that have too complex of a query a list of where to go should Spring Data JPA not offer what they need in query support. See #3005 --- src/main/asciidoc/jpa.adoc | 16 ++++++++++++++++ 1 file changed, 16 insertions(+) diff --git a/src/main/asciidoc/jpa.adoc b/src/main/asciidoc/jpa.adoc index 723989c40f..886aaee1b6 100644 --- a/src/main/asciidoc/jpa.adoc +++ b/src/main/asciidoc/jpa.adoc @@ -685,6 +685,22 @@ The escape character used can be configured by setting the `escapeCharacter` of Note that the method `escape(String)` available in the SpEL context will only escape the SQL and JPQL standard wildcards `_` and `%`. If the underlying database or the JPA implementation supports additional wildcards these will not get escaped. +[[jpa.query.other-methods]] +=== Other Methods + +Spring Data JPA offers many ways to build queries. +But sometimes, your query may simply be too complicated for the techniques offered. +In that situation, consider: + +* If you haven't already, simply write the query yourself using <>. +* Sometimes, you can put your query inside the database use Spring Data JPA's <>, or if it's a database function use the <> and invoke it with a `CALL`. +* If neither of these fit your needs, it may be time to implement a <>. This lets you register a method in your repository while leaving the implementation completely up to you. This gives you the ability to: +** Talk directly to the `EntityManager` (writing pure HQL/JPQL/EQL/native SQL or using the *Criteria API*) +** Leverage Spring Framework's `JdbcTemplate` (native SQL) +** Use another 3rd-party database toolkit. + +These tactics may be most effective when you need maximum control of your query, while still letting Spring Data JPA provide resource management. + [[jpa.modifying-queries]] === Modifying Queries