Skip to content

Commit 0157b17

Browse files
Merge branch 'main' of https://github.com/spring-projects/spring-data-commons into remote-unused-import
Signed-off-by: Tran Ngoc Nhan <ngocnhan.tran1996@gmail.com> # Conflicts: # src/main/java/org/springframework/data/util/TypeContributor.java
2 parents 809813c + 90aa3bd commit 0157b17

File tree

120 files changed

+8437
-2126
lines changed

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

120 files changed

+8437
-2126
lines changed

.github/workflows/codeql.yml

Lines changed: 21 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,21 @@
1+
# GitHub Actions for CodeQL Scanning
2+
3+
name: "CodeQL Advanced"
4+
5+
on:
6+
push:
7+
pull_request:
8+
workflow_dispatch:
9+
schedule:
10+
# https://docs.github.com/en/actions/writing-workflows/choosing-when-your-workflow-runs/events-that-trigger-workflows#schedule
11+
- cron: '0 5 * * *'
12+
13+
permissions: read-all
14+
15+
jobs:
16+
codeql-analysis-call:
17+
permissions:
18+
actions: read
19+
contents: read
20+
security-events: write
21+
uses: spring-io/github-actions/.github/workflows/codeql-analysis.yml@1

.github/workflows/project.yml

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -10,6 +10,11 @@ on:
1010
pull_request_target:
1111
types: [opened, edited, reopened]
1212

13+
permissions:
14+
contents: read
15+
issues: write
16+
pull-requests: write
17+
1318
jobs:
1419
Inbox:
1520
runs-on: ubuntu-latest

Jenkinsfile

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -9,7 +9,7 @@ pipeline {
99

1010
triggers {
1111
pollSCM 'H/10 * * * *'
12-
upstream(upstreamProjects: "spring-data-build/4.0.x", threshold: hudson.model.Result.SUCCESS)
12+
upstream(upstreamProjects: "spring-data-build/main", threshold: hudson.model.Result.SUCCESS)
1313
}
1414

1515
options {

ci/pipeline.properties

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
# Java versions
2-
java.main.tag=24.0.1_9-jdk-noble
3-
java.next.tag=24.0.1_9-jdk-noble
2+
java.main.tag=25-jdk-noble
3+
java.next.tag=25-jdk-noble
44

55
# Docker container images - standard
66
docker.java.main.image=library/eclipse-temurin:${java.main.tag}
@@ -14,6 +14,7 @@ docker.mongodb.8.0.version=8.0.9
1414
# Supported versions of Redis
1515
docker.redis.6.version=6.2.13
1616
docker.redis.7.version=7.2.4
17+
docker.valkey.8.version=8.1.1
1718

1819
# Docker environment settings
1920
docker.java.inside.basic=-v $HOME:/tmp/jenkins-home

pom.xml

Lines changed: 13 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -31,7 +31,7 @@
3131
<properties>
3232

3333
<scala>2.11.7</scala>
34-
<xmlbeam>1.4.25</xmlbeam>
34+
<xmlbeam>1.4.26</xmlbeam>
3535
<java-module-name>spring.data.commons</java-module-name>
3636
<kotlin.api.target>1.8</kotlin.api.target>
3737
</properties>
@@ -70,6 +70,11 @@
7070
<artifactId>jackson-databind</artifactId>
7171
<optional>true</optional>
7272
</dependency>
73+
<dependency>
74+
<groupId>tools.jackson.core</groupId>
75+
<artifactId>jackson-databind</artifactId>
76+
<optional>true</optional>
77+
</dependency>
7378
<dependency>
7479
<groupId>org.springframework</groupId>
7580
<artifactId>spring-web</artifactId>
@@ -319,6 +324,13 @@
319324
<scope>test</scope>
320325
</dependency>
321326

327+
<dependency>
328+
<groupId>org.jmolecules</groupId>
329+
<artifactId>jmolecules-ddd</artifactId>
330+
<version>${jmolecules}</version>
331+
<optional>true</optional>
332+
</dependency>
333+
322334
<dependency>
323335
<groupId>org.jmolecules.integrations</groupId>
324336
<artifactId>jmolecules-spring</artifactId>

src/main/antora/modules/ROOT/nav.adoc

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -21,6 +21,7 @@
2121
* xref:custom-conversions.adoc[]
2222
* xref:entity-callbacks.adoc[]
2323
* xref:is-new-state-detection.adoc[]
24+
* xref:aot.adoc[]
2425
* xref:kotlin.adoc[]
2526
** xref:kotlin/requirements.adoc[]
2627
** xref:kotlin/null-safety.adoc[]
Lines changed: 75 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,75 @@
1+
= Ahead of Time Optimizations
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].
4+
5+
[[aot.bestpractices]]
6+
== Best Practices
7+
8+
=== Annotate your Domain Types
9+
10+
During application startup, Spring scans the classpath for domain classes for early processing of entities.
11+
By annotating your domain types with Spring Data Store specific `@Table`, `@Document` or `@Entity` annotations you can aid initial entity scanning and ensure that those types are registered with `ManagedTypes` for Runtime Hints.
12+
Classpath scanning is not possible in native image arrangements and so Spring has to use `ManagedTypes` for the initial entity set.
13+
14+
[[aot.code-gen]]
15+
== Ahead of Time Code Generation
16+
17+
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.
18+
19+
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.
20+
21+
* Bytecode for generated Type/Property Accessors
22+
* Sourcecode for the defined Repository Interfaces
23+
* Repository Metadata in JSON format
24+
25+
Each of the above is enabled by default.
26+
However, there users may fine tune the configuration with following options.
27+
28+
[options = "autowidth",cols="1,1"]
29+
|===
30+
|`spring.aot.data.accessors.enabled`
31+
|Boolean flag to control contribution of Bytecode for generated Type/Property Accessors
32+
33+
|`spring.aot.data.accessors.include`
34+
|Comma separated list of FQCN for which to contribute Bytecode for generated Type/Property Accessors.
35+
Ant-style include patterns matching package names (e.g. `com.acme.**`) or type names inclusion.
36+
Inclusion pattern matches are evaluated before exclusions for broad exclusion and selective inclusion.
37+
38+
|`spring.aot.data.accessors.exclude`
39+
|Comma separated list of FQCN for which to skip contribution of Bytecode for generated Type/Property Accessors.
40+
Ant-style exclude patterns matching package names (e.g. `com.acme.**`) or type names exclusion.
41+
Exclusion pattern matches are evaluated after inclusions for broad exclusion and selective inclusion.
42+
43+
|`spring.aot.repositories.enabled`
44+
|Boolean flag to control contribution of Source Code for Repository Interfaces
45+
46+
|`spring.aot.[module-name].repositories.enabled`
47+
|Boolean flag to control contribution of Source Code for Repository Interfaces for a certain module (eg. `jdbc`, `jpa`, `mongodb`, `cassandra`)
48+
|===
49+
50+
[[aot.repositories]]
51+
== Ahead of Time Repositories
52+
53+
AOT Repositories are an extension to AOT processing by pre-generating eligible query method implementations.
54+
Query methods are opaque to developers regarding their underlying queries being executed in a query method call.
55+
AOT repositories contribute query method implementations based on derived, annotated, and named queries that are known at build-time.
56+
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.
57+
58+
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.
59+
60+
[[aot.hints]]
61+
== Native Image Runtime Hints
62+
63+
Running an application as a native image requires additional information compared to a regular JVM runtime.
64+
Spring Data contributes {spring-framework-docs}/core/aot.html#aot.hints[Runtime Hints] during AOT processing for native image usage.
65+
These are in particular hints for:
66+
67+
* Auditing
68+
* `ManagedTypes` to capture the outcome of class-path scans
69+
* Repositories
70+
** Reflection hints for entities, return types, and Spring Data annotations
71+
** Repository fragments
72+
** Querydsl `Q` classes
73+
** Kotlin Coroutine support
74+
* Web support (Jackson Hints for `PagedModel`)
75+

src/main/antora/modules/ROOT/pages/is-new-state-detection.adoc

Lines changed: 0 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -23,8 +23,4 @@ See the {spring-data-commons-javadoc-base}/org/springframework/data/domain/Persi
2323
_Note: Properties of `Persistable` will get detected and persisted if you use `AccessType.PROPERTY`.
2424
To avoid that, use `@Transient`._
2525

26-
|Providing a custom `EntityInformation` implementation
27-
|You can customize the `EntityInformation` abstraction used in the repository base implementation by creating a subclass of the module specific repository factory and overriding the `getEntityInformation(…)` method.
28-
You then have to register the custom implementation of module specific repository factory as a Spring bean.
29-
Note that this should rarely be necessary.
3026
|===

src/main/antora/modules/ROOT/pages/repositories/core-extensions-web.adoc

Lines changed: 9 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -290,9 +290,9 @@ By default, the assembler points to the controller method it was invoked in, but
290290
== Spring Data Jackson Modules
291291

292292
The core module, and some of the store specific ones, ship with a set of Jackson Modules for types, like `org.springframework.data.geo.Distance` and `org.springframework.data.geo.Point`, used by the Spring Data domain. +
293-
Those Modules are imported once xref:repositories/core-extensions.adoc#core.web[web support] is enabled and `com.fasterxml.jackson.databind.ObjectMapper` is available.
293+
Those modules are imported once xref:repositories/core-extensions.adoc#core.web[web support] is enabled and `tools.jackson.databind.ObjectMapper` is available.
294294

295-
During initialization `SpringDataJacksonModules`, like the `SpringDataJacksonConfiguration`, get picked up by the infrastructure, so that the declared ``com.fasterxml.jackson.databind.Module``s are made available to the Jackson `ObjectMapper`.
295+
During initialization `SpringDataJackson3Modules`, like the `SpringDataJackson3Configuration`, get picked up by the infrastructure, so that the declared ``tools.jackson.databind.JacksonModule``s are made available to the Jackson `ObjectMapper`.
296296

297297
Data binding mixins for the following domain types are registered by the common infrastructure.
298298

@@ -306,10 +306,15 @@ org.springframework.data.geo.Polygon
306306

307307
[NOTE]
308308
====
309-
The individual module may provide additional `SpringDataJacksonModules`. +
309+
The individual module may provide additional `SpringDataJackson3Modules`. +
310310
Please refer to the store specific section for more details.
311311
====
312312

313+
[NOTE]
314+
====
315+
Jackson 2 support is deprecated and will be removed in a future release.
316+
====
317+
313318
[[core.web.binding]]
314319
== Web Databinding Support
315320

@@ -341,7 +346,7 @@ Nested projections are supported as described in xref:repositories/projections.a
341346
If the method returns a complex, non-interface type, a Jackson `ObjectMapper` is used to map the final value.
342347

343348
For Spring MVC, the necessary converters are registered automatically as soon as `@EnableSpringDataWebSupport` is active and the required dependencies are available on the classpath.
344-
For usage with `RestTemplate`, register a `ProjectingJackson2HttpMessageConverter` (JSON) or `XmlBeamHttpMessageConverter` manually.
349+
For usage with `RestTemplate`, register a `ProjectingJacksonHttpMessageConverter` (JSON) or `XmlBeamHttpMessageConverter` manually.
345350

346351
For more information, see the https://github.com/spring-projects/spring-data-examples/tree/main/web/projection[web projection example] in the canonical https://github.com/spring-projects/spring-data-examples[Spring Data Examples repository].
347352

src/main/antora/modules/ROOT/pages/repositories/create-instances.adoc

Lines changed: 33 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -27,6 +27,39 @@ class ApplicationConfiguration {
2727

2828
NOTE: The preceding example uses the JPA-specific annotation, which you would change according to the store module you actually use. The same applies to the definition of the `EntityManagerFactory` bean. See the sections covering the store-specific configuration.
2929

30+
[[repositories.create-instances.java-config.placeholders-and-patterns]]
31+
=== Property Placeholders and Ant-style Patterns
32+
33+
The `basePackages` and `value` attributes in `@Enable{store}Repositories` support `${…}` property placeholders which are resolved against the `Environment` as well as Ant-style package patterns such as `"org.example.+++**+++"`.
34+
35+
The following example specifies the `app.scan.packages` property placeholder for the implicit `value` attribute in `@Enable{store}Repositories`.
36+
37+
[tabs]
38+
======
39+
Java::
40+
+
41+
[source,java,indent=0,subs="verbatim,quotes,attributes,specialchars"]
42+
----
43+
@Configuration
44+
@Enable{store}Repositories("${app.scan.packages}") // <1>
45+
public class ApplicationConfiguration {
46+
// …
47+
}
48+
----
49+
<1> `app.scan.packages` property placeholder to be resolved against the `Environment`
50+
51+
Kotlin::
52+
+
53+
[source,kotlin,indent=0,subs="verbatim,quotes,attributes,specialchars"]
54+
----
55+
@Enable{store}Repositories(["\${app.scan.packages}"]) // <1>
56+
class ApplicationConfiguration {
57+
// …
58+
}
59+
----
60+
<1> `app.scan.packages` property placeholder to be resolved against the `Environment`
61+
======
62+
3063
ifeval::[{include-xml-namespaces} != false]
3164
[[repositories.create-instances.spring]]
3265
[[repositories.create-instances.xml]]

0 commit comments

Comments
 (0)