Skip to content

Commit 80916d4

Browse files
committed
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 Original Pull Request: #3006
1 parent 2e489cb commit 80916d4

File tree

1 file changed

+16
-0
lines changed

1 file changed

+16
-0
lines changed

src/main/asciidoc/jpa.adoc

+16
Original file line numberDiff line numberDiff line change
@@ -685,6 +685,22 @@ The escape character used can be configured by setting the `escapeCharacter` of
685685
Note that the method `escape(String)` available in the SpEL context will only escape the SQL and JPQL standard wildcards `_` and `%`.
686686
If the underlying database or the JPA implementation supports additional wildcards these will not get escaped.
687687

688+
[[jpa.query.other-methods]]
689+
=== Other Methods
690+
691+
Spring Data JPA offers many ways to build queries.
692+
But sometimes, your query may simply be too complicated for the techniques offered.
693+
In that situation, consider:
694+
695+
* If you haven't already, simply write the query yourself using <<jpa.query-methods.at-query,`@Query`>>.
696+
* 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:
697+
** Talk directly to the `EntityManager` (writing pure HQL/JPQL/EQL/native SQL or using the *Criteria API*)
698+
** Leverage Spring Framework's `JdbcTemplate` (native SQL)
699+
** Use another 3rd-party database toolkit.
700+
* 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`.
701+
702+
These tactics may be most effective when you need maximum control of your query, while still letting Spring Data JPA provide resource management.
703+
688704
[[jpa.modifying-queries]]
689705
=== Modifying Queries
690706

0 commit comments

Comments
 (0)