From 616f052238e020c1e747cd53b230ae08a51df5c7 Mon Sep 17 00:00:00 2001 From: Jens Schauder Date: Wed, 5 Nov 2025 10:21:46 +0100 Subject: [PATCH 1/2] aot-doc - Prepare branch --- pom.xml | 2 +- spring-data-mongodb-distribution/pom.xml | 2 +- spring-data-mongodb/pom.xml | 2 +- 3 files changed, 3 insertions(+), 3 deletions(-) diff --git a/pom.xml b/pom.xml index b23a16229f..7bcc807289 100644 --- a/pom.xml +++ b/pom.xml @@ -5,7 +5,7 @@ org.springframework.data spring-data-mongodb-parent - 5.0.0-SNAPSHOT + 5.0.0-aot-doc-SNAPSHOT pom Spring Data MongoDB diff --git a/spring-data-mongodb-distribution/pom.xml b/spring-data-mongodb-distribution/pom.xml index fc88571622..5713282f07 100644 --- a/spring-data-mongodb-distribution/pom.xml +++ b/spring-data-mongodb-distribution/pom.xml @@ -15,7 +15,7 @@ org.springframework.data spring-data-mongodb-parent - 5.0.0-SNAPSHOT + 5.0.0-aot-doc-SNAPSHOT ../pom.xml diff --git a/spring-data-mongodb/pom.xml b/spring-data-mongodb/pom.xml index 37730f7d40..aa1d9504df 100644 --- a/spring-data-mongodb/pom.xml +++ b/spring-data-mongodb/pom.xml @@ -13,7 +13,7 @@ org.springframework.data spring-data-mongodb-parent - 5.0.0-SNAPSHOT + 5.0.0-aot-doc-SNAPSHOT ../pom.xml From 8198ee2ede7e0481d5908b0f1935d6ecdb79b4f0 Mon Sep 17 00:00:00 2001 From: Jens Schauder Date: Wed, 5 Nov 2025 09:47:56 +0100 Subject: [PATCH 2/2] Reduce duplicate AOT documentation. Removed all the generic AOT documentation with a reference to the section in Spring Data Commons See #https://github.com/spring-projects/spring-data-commons/pull/3384 --- .../modules/ROOT/pages/mongodb/aot.adoc | 67 ++----------------- 1 file changed, 4 insertions(+), 63 deletions(-) diff --git a/src/main/antora/modules/ROOT/pages/mongodb/aot.adoc b/src/main/antora/modules/ROOT/pages/mongodb/aot.adoc index 7a2e5f28d2..e239c8c337 100644 --- a/src/main/antora/modules/ROOT/pages/mongodb/aot.adoc +++ b/src/main/antora/modules/ROOT/pages/mongodb/aot.adoc @@ -1,69 +1,10 @@ = Ahead of Time Optimizations -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]. +For a general explanation of what Ahead of Time (AoT) Optimizations Spring Data offers and how to enable them see +xref:{commons}@data-commons::page$aot.adoc[] -[[aot.hints]] -== Runtime Hints - -Running an application as a native image requires additional information compared to a regular JVM runtime. -Spring Data contributes {spring-framework-docs}/core/aot.html#aot.hints[Runtime Hints] during AOT processing for native image usage. -These are in particular hints for: - -* Auditing -* `ManagedTypes` to capture the outcome of class-path scans -* Repositories -** Reflection hints for entities, return types, and Spring Data annotations -** Repository fragments -** Querydsl `Q` classes -** Kotlin Coroutine support -* Web support (Jackson Hints for `PagedModel`) - -[[aot.repositories]] -== Ahead of Time Repositories - -AOT Repositories are an extension to AOT processing by pre-generating eligible query method implementations. -Query methods are opaque to developers regarding their underlying queries being executed in a query method call. -AOT repositories contribute query method implementations based on derived or annotated queries, updates or aggregations that are known at build-time. -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. - -The resulting AOT repository fragment follows the naming scheme of `Impl__Aot` and is placed in the same package as the repository interface. -You can find all queries in their MQL form for generated repository query methods. - -[TIP] -==== -`spring.aot.repositories.enabled` property needs to be set to `true` for repository fragment code generation. -==== - -[NOTE] -==== -Consider AOT repository classes an internal optimization. -Do not use them directly in your code as generation and implementation details may change in future releases. -==== - -=== Running with AOT Repositories - -AOT is a mandatory step to transform a Spring application to a native executable, so it is automatically enabled when running in this mode. -When AOT is enabled (either for native compilation or by setting `spring.aot.enabled=true`), AOT repositories are automatically enabled by default. - -You can disable AOT repository generation entirely or only disable MongoDB AOT repositories: - -* Set the `spring.aot.repositories.enabled=false` property to disable generated repositories for all Spring Data modules. -* Set the `spring.aot.mongodb.repositories.enabled=false` property to disable only MongoDB AOT repositories. - -AOT repositories contribute configuration changes to the actual repository bean registration to register the generated repository fragment. - -[NOTE] -==== -When AOT optimizations are included, some decisions that have been taken at build-time are hard-coded in the application setup. -For instance, profiles that have been enabled at build-time are automatically enabled at runtime as well. -Also, the Spring Data module implementing a repository is fixed. -Changing the implementation requires AOT re-processing. -==== - -=== Eligible Methods in Data MongoDB - -AOT repositories filter methods that are eligible for AOT processing. -These are typically all query methods that are not backed by an xref:repositories/custom-implementations.adoc[implementation fragment]. +Each module offers optimizations for a slightly different set of repository method. +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. **Supported Features**