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: src/main/asciidoc/jdbc.adoc
+14-1Lines changed: 14 additions & 1 deletion
Original file line number
Diff line number
Diff line change
@@ -388,7 +388,7 @@ This section offers some specific information about the implementation and use o
388
388
[[jdbc.query-methods.strategies]]
389
389
=== Query Lookup Strategies
390
390
391
-
The JDBC module supports defining a query manually only as a String in a `@Query` annotation.
391
+
The JDBC module supports defining a query manually as a String in a `@Query` annotation or as named query in a property file.
392
392
Deriving a query from the name of the method is currently not supported.
393
393
394
394
[[jdbc.query-methods.at-query]]
@@ -413,6 +413,19 @@ NOTE: Spring fully supports Java 8’s parameter name discovery based on the `-p
413
413
NOTE: Spring Data JDBC supports only named parameters.
414
414
415
415
416
+
[[jdbc.query-methods.named-query]]
417
+
=== Named Queries
418
+
419
+
If no query is given in an annotation as described in the previous section Spring Data JDBC will try to locate a named query.
420
+
There are two ways how the name of the query can be determined.
421
+
The default is to take the _domain class_ of the query, i.e. the aggregate root of the repository, take its simple name and append the name of the method separated by a `.`.
422
+
Alternatively the `@Query` annotation has a `name` attribute which can be used to specify the name of a query to be looked up.
423
+
424
+
Named queries are expected to be provided in the property file `META-INF/jdbc-named-queries.properties` on the classpath.
425
+
426
+
The location of that file may be changed by setting a value to `@EnableJdbcRepositories.namedQueriesLocation`.
0 commit comments