Skip to content

Commit 8420a56

Browse files
committed
DATAJDBC-234 - Adds documentation.
Original pull request: #180.
1 parent 09fd0fc commit 8420a56

File tree

1 file changed

+14
-1
lines changed

1 file changed

+14
-1
lines changed

src/main/asciidoc/jdbc.adoc

Lines changed: 14 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -388,7 +388,7 @@ This section offers some specific information about the implementation and use o
388388
[[jdbc.query-methods.strategies]]
389389
=== Query Lookup Strategies
390390

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.
392392
Deriving a query from the name of the method is currently not supported.
393393

394394
[[jdbc.query-methods.at-query]]
@@ -413,6 +413,19 @@ NOTE: Spring fully supports Java 8’s parameter name discovery based on the `-p
413413
NOTE: Spring Data JDBC supports only named parameters.
414414

415415

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`.
427+
428+
416429
[[jdbc.query-methods.at-query.custom-rowmapper]]
417430
==== Custom `RowMapper`
418431

0 commit comments

Comments
 (0)