-
Notifications
You must be signed in to change notification settings - Fork 699
Update documentation #3384
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Draft
christophstrobl
wants to merge
3
commits into
main
Choose a base branch
from
issue/3383
base: main
Could not load branches
Branch not found: {{ refName }}
Loading
Could not load tags
Nothing to show
Loading
Are you sure you want to change the base?
Some commits from the old base branch may be removed from the timeline,
and old review comments may become outdated.
+91
−5
Draft
Update documentation #3384
Changes from all commits
Commits
File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -1,3 +1,4 @@ | ||
| [[aot]] | ||
| = 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]. | ||
|
|
@@ -16,6 +17,11 @@ Classpath scanning is not possible in native image arrangements and so Spring ha | |
|
|
||
| Ahead of time code generation is not limited to usage with GraalVM Native Image but also offers benefits when working with regular deployments and can help optimize startup performance on the jvm. | ||
|
|
||
| [NOTE] | ||
| ==== | ||
| With AOT optimizations some decisions (like database dialects for example) will be frozen at build time and get included as is in the application setup. | ||
| ==== | ||
|
|
||
| If Ahead of Time compilation is enabled Spring Data can (depending on the actual Module in use) contribute several components during the AOT phase of your build. | ||
|
|
||
| * Bytecode for generated Type/Property Accessors | ||
|
|
@@ -32,30 +38,110 @@ However, there users may fine tune the configuration with following options. | |
|
|
||
| |`spring.aot.data.accessors.include` | ||
| |Comma separated list of FQCN for which to contribute Bytecode for generated Type/Property Accessors. | ||
| Ant-style include patterns matching package names (e.g. `com.acme.**`) or type names inclusion. | ||
| Ant-style include patterns matching package names (e.g. `example.springdata.**`) or type names inclusion. | ||
| Inclusion pattern matches are evaluated before exclusions for broad exclusion and selective inclusion. | ||
|
|
||
| |`spring.aot.data.accessors.exclude` | ||
| |Comma separated list of FQCN for which to skip contribution of Bytecode for generated Type/Property Accessors. | ||
| Ant-style exclude patterns matching package names (e.g. `com.acme.**`) or type names exclusion. | ||
| Ant-style exclude patterns matching package names (e.g. `example.springdata.**`) or type names exclusion. | ||
| Exclusion pattern matches are evaluated after inclusions for broad exclusion and selective inclusion. | ||
|
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. See above. |
||
|
|
||
| |`spring.aot.repositories.enabled` | ||
| |Boolean flag to control contribution of Source Code for Repository Interfaces | ||
|
|
||
| |`spring.aot.[module-name].repositories.enabled` | ||
| |Boolean flag to control contribution of Source Code for Repository Interfaces for a certain module (eg. `jdbc`, `jpa`, `mongodb`, `cassandra`) | ||
| |Boolean flag to control contribution of Source Code for Repository Interfaces for a certain module (eg. `cassandra`, `jdbc`, `jpa`, `mongodb`) | ||
|
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. eg. -> e.g. |
||
|
|
||
| |`spring.aot.repositories.metadata.enabled` | ||
| |Boolean flag to control contribution of JSON repository metadata containing query methods and actual query strings. | ||
| Requires `spring.aot.repositories.enabled` to be enabled. | ||
| |=== | ||
|
|
||
| [[aot.repositories]] | ||
| == Ahead of Time Repositories | ||
|
|
||
| [NOTE] | ||
| ==== | ||
| Ahead of Time repositories are only available for imperative (non reactive) repository interfaces of certain modules. | ||
| The criteria identifying eligible query methods varies between the implementing modules. | ||
| ==== | ||
|
|
||
| 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, annotated, and named queries that are known at build-time. | ||
| This optimization moves query method processing from runtime to build-time, which can lead to a significant 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 `<Repository FQCN>Impl_AotRepository` and is placed in the same package as the repository interface. | ||
| The resulting AOT repository fragment follows the naming scheme of `<Repository FQCN>Impl__AotRepository` and is placed in the same package as the repository interface. | ||
|
|
||
| [WARNING] | ||
| ==== | ||
| 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. | ||
| ==== | ||
|
|
||
| [[aot.repositories.json]] | ||
| === Repository Metadata | ||
|
|
||
| AOT processing introspects query methods and collects metadata about repository queries. | ||
| Spring Data stores this metadata in JSON files that are named after the source repository within the same package. | ||
| Repository JSON Metadata contains details about queries and fragments. | ||
| An example for the following repository is shown below: | ||
|
|
||
| [tabs] | ||
| ====== | ||
| Metadata:: | ||
| + | ||
| [source,json,role="primary"] | ||
| ---- | ||
| { | ||
| "name": "example.springdata.UserRepository", | ||
| "module": "JDBC", | ||
| "type": "IMPERATIVE", | ||
| "methods": [ | ||
| { | ||
| "name": "findBy", | ||
| "signature": "public abstract java.util.List<example.springdata.User> example.springdata.UserRepository.findBy()", | ||
| "query": { | ||
| "query": "SELECT * FROM User" | ||
| } | ||
| }, | ||
| { | ||
| "name": "findByLastnameStartingWith", | ||
| "signature": "public abstract org.springframework.data.domain.Page<example.springdata.User> example.springdata.UserRepository.findByLastnameStartingWith(java.lang.String,org.springframework.data.domain.Pageable)", | ||
| "query": { | ||
| "query": "SELECT * FROM User u WHERE lastname LIKE :lastname", | ||
| "count-query": "SELECT COUNT(*) FROM User WHERE lastname LIKE :lastname" | ||
| } | ||
| }, | ||
| { | ||
| "name": "findByEmailAddress", | ||
| "signature": "public abstract example.springdata.User example.springdata.UserRepository.findByEmailAddress(java.lang.String)", | ||
| "query": { | ||
| "query": "select * from User where emailAddress = ?1" | ||
| } | ||
| }, | ||
| ---- | ||
|
|
||
| Repository:: | ||
| + | ||
| [source,java,subs="attributes,specialchars",role="secondary"] | ||
| ---- | ||
| interface UserRepository extends CrudRepository<User, Integer> { | ||
|
|
||
| List<User> findBy(); | ||
|
|
||
| Page<User> findByLastnameStartingWith(String lastname, Pageable page); | ||
|
|
||
| @Query("select * from User where emailAddress = ?1") | ||
| User findByEmailAddress(String username); | ||
| } | ||
| ---- | ||
| ====== | ||
|
|
||
| [NOTE] | ||
| ==== | ||
| Creating JSON metadata can be controlled via the `spring.aot.repositories.metadata.enabled` flag. | ||
| ==== | ||
|
|
||
| [[aot.hints]] | ||
| == Native Image Runtime Hints | ||
|
|
||
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
Uh oh!
There was an error while loading. Please reload this page.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I find this order of evaluation business rather confusing, because it is really about precedence.
Something like this seems easier to understand.
If a type is matched by a inclusion and an exclusion, the exclusion wins and the type is considered excluded.