|
1 | 1 | = Ahead of Time Optimizations |
2 | 2 |
|
3 | | -This chapter covers Spring Data's Ahead of Time (AOT) optimizations that build upon {spring-framework-docs}/core/aot.html[Spring's Ahead of Time Optimizations]. |
| 3 | +For a general explanation of what Ahead of Time (AoT) Optimizations Spring Data offers and how to enable them see |
| 4 | +xref:{commons}@data-commons::page$aot.adoc[] |
4 | 5 |
|
5 | | -[[aot.hints]] |
6 | | -== Runtime Hints |
7 | | - |
8 | | -Running an application as a native image requires additional information compared to a regular JVM runtime. |
9 | | -Spring Data contributes {spring-framework-docs}/core/aot.html#aot.hints[Runtime Hints] during AOT processing for native image usage. |
10 | | -These are in particular hints for: |
11 | | - |
12 | | -* Auditing |
13 | | -* `ManagedTypes` to capture the outcome of class-path scans |
14 | | -* Repositories |
15 | | -** Reflection hints for entities, return types, and Spring Data annotations |
16 | | -** Repository fragments |
17 | | -** Querydsl `Q` classes |
18 | | -** Kotlin Coroutine support |
19 | | -* Web support (Jackson Hints for `PagedModel`) |
20 | | - |
21 | | -[[aot.repositories]] |
22 | | -== Ahead of Time Repositories |
23 | | - |
24 | | -AOT Repositories are an extension to AOT processing by pre-generating eligible query method implementations. |
25 | | -Query methods are opaque to developers regarding their underlying queries being executed in a query method call. |
26 | | -AOT repositories contribute query method implementations based on derived or annotated queries, updates or aggregations that are known at build-time. |
27 | | -This optimization moves query method processing from runtime to build-time, which can lead to a significant bootstrap performance improvement as query methods do not need to be analyzed reflectively upon each application start. |
28 | | - |
29 | | -The resulting AOT repository fragment follows the naming scheme of `<Repository FQCN>Impl__Aot` and is placed in the same package as the repository interface. |
30 | | -You can find all queries in their MQL form for generated repository query methods. |
31 | | - |
32 | | -[TIP] |
33 | | -==== |
34 | | -`spring.aot.repositories.enabled` property needs to be set to `true` for repository fragment code generation. |
35 | | -==== |
36 | | - |
37 | | -[NOTE] |
38 | | -==== |
39 | | -Consider AOT repository classes an internal optimization. |
40 | | -Do not use them directly in your code as generation and implementation details may change in future releases. |
41 | | -==== |
42 | | - |
43 | | -=== Running with AOT Repositories |
44 | | - |
45 | | -AOT is a mandatory step to transform a Spring application to a native executable, so it is automatically enabled when running in this mode. |
46 | | -When AOT is enabled (either for native compilation or by setting `spring.aot.enabled=true`), AOT repositories are automatically enabled by default. |
47 | | - |
48 | | -You can disable AOT repository generation entirely or only disable MongoDB AOT repositories: |
49 | | - |
50 | | -* Set the `spring.aot.repositories.enabled=false` property to disable generated repositories for all Spring Data modules. |
51 | | -* Set the `spring.aot.mongodb.repositories.enabled=false` property to disable only MongoDB AOT repositories. |
52 | | - |
53 | | -AOT repositories contribute configuration changes to the actual repository bean registration to register the generated repository fragment. |
54 | | - |
55 | | -[NOTE] |
56 | | -==== |
57 | | -When AOT optimizations are included, some decisions that have been taken at build-time are hard-coded in the application setup. |
58 | | -For instance, profiles that have been enabled at build-time are automatically enabled at runtime as well. |
59 | | -Also, the Spring Data module implementing a repository is fixed. |
60 | | -Changing the implementation requires AOT re-processing. |
61 | | -==== |
62 | | - |
63 | | -=== Eligible Methods in Data MongoDB |
64 | | - |
65 | | -AOT repositories filter methods that are eligible for AOT processing. |
66 | | -These are typically all query methods that are not backed by an xref:repositories/custom-implementations.adoc[implementation fragment]. |
| 6 | +Each module offers optimizations for a slightly different set of repository method. |
| 7 | +With Spring Data MongoDb we generally support query methods that are not backed by an xref:repositories/custom-implementations.adoc[implementation fragment], and don't require, with a few limitations detailed below. |
67 | 8 |
|
68 | 9 | **Supported Features** |
69 | 10 |
|
|
0 commit comments