Skip to content

Commit a9e1f66

Browse files
committed
Provide anchors for fourth level sections.
Closes #2129 Original pull request #2131
1 parent ca9ab0a commit a9e1f66

File tree

1 file changed

+8
-0
lines changed

1 file changed

+8
-0
lines changed

src/main/asciidoc/jpa.adoc

+8
Original file line numberDiff line numberDiff line change
@@ -37,6 +37,7 @@ The JPA module of Spring Data contains a custom namespace that allows defining r
3737

3838
Using the `repositories` element looks up Spring Data repositories as described in "`<<repositories.create-instances>>`". Beyond that, it activates persistence exception translation for all beans annotated with `@Repository`, to let exceptions being thrown by the JPA persistence providers be converted into Spring's `DataAccessException` hierarchy.
3939

40+
[[jpa.namespace.custom-namespace-attributes]]
4041
==== Custom Namespace Attributes
4142
Beyond the default attributes of the `repositories` element, the JPA namespace offers additional attributes to let you gain more detailed control over the setup of the repositories:
4243

@@ -114,6 +115,7 @@ That means, that repositories will not get instantiated if the client bean is si
114115
Repository instances will be initialized and verified upon first interaction with the repository.
115116
* `DEFERRED` -- Fundamentally the same mode of operation as `LAZY`, but triggering repository initialization in response to an `ContextRefreshedEvent` so that repositories are verified before the application has completely started.
116117

118+
[[jpa.bootstrap-mode.recommendations]]
117119
==== Recommendations
118120

119121
If you're not using asynchronous JPA bootstrap stick with the default bootstrap mode.
@@ -196,6 +198,7 @@ This means if the arguments actually contain characters recognized by `LIKE` as
196198
The escape character used can be configured by setting the `escapeCharacter` of the `@EnableJpaRepositories` annotation.
197199
Compare with <<jpa.query.spel-expressions>>.
198200

201+
[[jpa.query-methods.declared-queries]]
199202
==== Declared Queries
200203
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).
201204

@@ -255,6 +258,7 @@ NOTE: `In` and `NotIn` also take any subclass of `Collection` as a parameter as
255258

256259
NOTE: The examples use the `<named-query />` element and `@NamedQuery` annotation. The queries for these configuration elements have to be defined in the JPA query language. Of course, you can use `<named-native-query />` or `@NamedNativeQuery` too. These elements let you define the query in native SQL by losing the database platform independence.
257260

261+
[[jpa.query-methods.named-queries.xml-named-query-definition]]
258262
==== XML Named Query Definition
259263
To use XML configuration, add the necessary `<named-query />` element to the `orm.xml` JPA configuration file located in the `META-INF` folder of your classpath. Automatic invocation of named queries is enabled by using some defined naming convention. For more details, see below.
260264

@@ -270,6 +274,7 @@ To use XML configuration, add the necessary `<named-query />` element to the `or
270274

271275
The query has a special name that is used to resolve it at runtime.
272276

277+
[[jpa.query-methods.named-queries.annotation-based-configuration]]
273278
==== Annotation-based Configuration
274279
Annotation-based configuration has the advantage of not needing another configuration file to be edited, lowering maintenance effort. You pay for that benefit by the need to recompile your domain class for every new query declaration.
275280

@@ -286,6 +291,7 @@ public class User {
286291
----
287292
====
288293

294+
[[jpa.query-methods.named-queries.declaring-interfaces]]
289295
==== Declaring Interfaces
290296
To allow these named queries, specify the `UserRepository` as follows:
291297

@@ -326,6 +332,7 @@ public interface UserRepository extends JpaRepository<User, Long> {
326332
----
327333
====
328334

335+
[[jpa.query-methods.at-query.advanced-like]]
329336
==== Using Advanced `LIKE` Expressions
330337

331338
The query running mechanism for manually defined queries created with `@Query` allows the definition of advanced `LIKE` expressions inside the query definition, as shown in the following example:
@@ -344,6 +351,7 @@ public interface UserRepository extends JpaRepository<User, Long> {
344351

345352
In the preceding example, the `LIKE` delimiter character (`%`) is recognized, and the query is transformed into a valid JPQL query (removing the `%`). Upon running the query, the parameter passed to the method call gets augmented with the previously recognized `LIKE` pattern.
346353

354+
[[jpa.query-methods.at-query.native]]
347355
==== Native Queries
348356

349357
The `@Query` annotation allows for running native queries by setting the `nativeQuery` flag to true, as shown in the following example:

0 commit comments

Comments
 (0)