Compare commits
176 Commits
4.0.0-M5
...
issue/arch
| Author | SHA1 | Date | |
|---|---|---|---|
|
|
171f6641c7 | ||
|
|
4f8c29f48a | ||
|
|
e3ef84a56c | ||
|
|
3ab78fc1ed | ||
|
|
fa0f026410 | ||
|
|
9c96a2b2c3 | ||
|
|
0986210221 | ||
|
|
7d5372f049 | ||
|
|
a5022e9bc4 | ||
|
|
aff8fbd62a | ||
|
|
633fbceb5a | ||
|
|
fb9a0d8482 | ||
|
|
d73807df1b | ||
|
|
e56f6ce87f | ||
|
|
c5c6fc107c | ||
|
|
368c644922 | ||
|
|
4d050f5021 | ||
|
|
83923e0e2a | ||
|
|
25588850dd | ||
|
|
55c81f4f54 | ||
|
|
ac7551e47f | ||
|
|
6d3043de9a | ||
|
|
1a94b6e4ee | ||
|
|
33902b5061 | ||
|
|
d00db4bd40 | ||
|
|
a5dcbf043a | ||
|
|
c31203582f | ||
|
|
f146afecdc | ||
|
|
324a541a64 | ||
|
|
6b71d773d7 | ||
|
|
10447afe0c | ||
|
|
c9dfd60f0f | ||
|
|
26a8fafd03 | ||
|
|
00f652a094 | ||
|
|
d050ae5732 | ||
|
|
8bcab93588 | ||
|
|
1839f55055 | ||
|
|
4220df5bf8 | ||
|
|
95c6d1531f | ||
|
|
b7ed099e06 | ||
|
|
7e2e546e55 | ||
|
|
7ce2ebe26e | ||
|
|
fbf4d1baa8 | ||
|
|
187f260fe4 | ||
|
|
04411075b4 | ||
|
|
459a9c191b | ||
|
|
137cba8bbb | ||
|
|
548cbd87b6 | ||
|
|
02647ad125 | ||
|
|
fe549f7254 | ||
|
|
c069e094e6 | ||
|
|
62f3656ebb | ||
|
|
cbc718e03d | ||
|
|
23be69b9ce | ||
|
|
b7b5b085b3 | ||
|
|
2d292c50b0 | ||
|
|
f959a77890 | ||
|
|
c04c3d66a3 | ||
|
|
b204c1b33e | ||
|
|
dfa029b341 | ||
|
|
04a8c47cda | ||
|
|
88ea57f2be | ||
|
|
521bbd2535 | ||
|
|
0474632640 | ||
|
|
8aab5e5a01 | ||
|
|
3db5fc728e | ||
|
|
b027f15a4c | ||
|
|
fd0a554d59 | ||
|
|
d4daa305a8 | ||
|
|
2d63d6006d | ||
|
|
5007e68cc1 | ||
|
|
3ea4e0f9dd | ||
|
|
e9ac77c058 | ||
|
|
daef8b6e8e | ||
|
|
f671a9bd43 | ||
|
|
57b52862c8 | ||
|
|
af917b9465 | ||
|
|
ee545487b8 | ||
|
|
240e53794c | ||
|
|
7b6a06888d | ||
|
|
034a3528af | ||
|
|
ff28789507 | ||
|
|
cdfdeafdac | ||
|
|
16a35e0329 | ||
|
|
79f05c3d7f | ||
|
|
9217821472 | ||
|
|
8d223abd05 | ||
|
|
6a973b245f | ||
|
|
714b23e0ce | ||
|
|
d4a6614c11 | ||
|
|
82ce0abe1a | ||
|
|
dec7c125d6 | ||
|
|
db12c4ba5a | ||
|
|
5bbe481e98 | ||
|
|
fb39c31986 | ||
|
|
dd446472bc | ||
|
|
72d82d3083 | ||
|
|
cdfe2a0b59 | ||
|
|
5525a4fbf9 | ||
|
|
59464f3b3c | ||
|
|
052cfdfd45 | ||
|
|
b31c21bb91 | ||
|
|
5b6e5ca568 | ||
|
|
1a9136c0c1 | ||
|
|
59753bb55a | ||
|
|
8d963fc5da | ||
|
|
c1de745014 | ||
|
|
aa35aaeb70 | ||
|
|
a5725806f5 | ||
|
|
d715414683 | ||
|
|
f2c2451b7d | ||
|
|
5b8d0d08ee | ||
|
|
18186f26e2 | ||
|
|
10acc14c14 | ||
|
|
87effb9013 | ||
|
|
19819680f9 | ||
|
|
2d2f67cc93 | ||
|
|
e9818fe11a | ||
|
|
a63db5586c | ||
|
|
68ab74a5bf | ||
|
|
de33734118 | ||
|
|
c272c7317e | ||
|
|
d7fc605f7b | ||
|
|
3b805b9e03 | ||
|
|
91cca3f2c4 | ||
|
|
2de6384d0f | ||
|
|
ab1c0ff7b8 | ||
|
|
ae2846c5bf | ||
|
|
e88c9cf791 | ||
|
|
fadca10f62 | ||
|
|
40320136f3 | ||
|
|
bc575de3b0 | ||
|
|
09b2afa79d | ||
|
|
96b564eb9a | ||
|
|
38390d3475 | ||
|
|
6937bb519b | ||
|
|
6e4d463053 | ||
|
|
a9d2050806 | ||
|
|
6676389062 | ||
|
|
81f85b8cca | ||
|
|
77f318bd77 | ||
|
|
7c7e70418f | ||
|
|
44a1123034 | ||
|
|
e487c08b0c | ||
|
|
a002d30aa9 | ||
|
|
36ddd26edc | ||
|
|
6197655e98 | ||
|
|
929faea88b | ||
|
|
1fe1c13531 | ||
|
|
838ddb5d26 | ||
|
|
33c7f0980f | ||
|
|
4bbc443a0e | ||
|
|
655dbc9783 | ||
|
|
0d752fd6e6 | ||
|
|
8aabf2fa5e | ||
|
|
ff9d338bd7 | ||
|
|
2a4ee12363 | ||
|
|
a66438fc20 | ||
|
|
0ccc037b8e | ||
|
|
00792192c3 | ||
|
|
e064b505c9 | ||
|
|
7df2bdf8ff | ||
|
|
2f9fc1618e | ||
|
|
9e2aecf4ae | ||
|
|
c32c4beb59 | ||
|
|
d48f3ec535 | ||
|
|
5f16aecd13 | ||
|
|
5fc49b1649 | ||
|
|
1e7dc7ce66 | ||
|
|
234783f442 | ||
|
|
3429350964 | ||
|
|
d130984bdc | ||
|
|
f5378bf825 | ||
|
|
21057c3d17 | ||
|
|
d0a98eb71d | ||
|
|
bc95c4d390 |
4
.mvn/wrapper/maven-wrapper.properties
vendored
4
.mvn/wrapper/maven-wrapper.properties
vendored
@@ -1,2 +1,2 @@
|
|||||||
#Fri Jun 03 09:32:40 CEST 2022
|
#Mon Feb 20 11:58:01 CET 2023
|
||||||
distributionUrl=https\://repo.maven.apache.org/maven2/org/apache/maven/apache-maven/3.8.5/apache-maven-3.8.5-bin.zip
|
distributionUrl=https\://repo.maven.apache.org/maven2/org/apache/maven/apache-maven/3.9.0/apache-maven-3.9.0-bin.zip
|
||||||
|
|||||||
43
Jenkinsfile
vendored
43
Jenkinsfile
vendored
@@ -58,6 +58,25 @@ pipeline {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
stage('Publish JDK (Java 17) + MongoDB 6.0') {
|
||||||
|
when {
|
||||||
|
anyOf {
|
||||||
|
changeset "ci/openjdk17-mongodb-6.0/**"
|
||||||
|
changeset "ci/pipeline.properties"
|
||||||
|
}
|
||||||
|
}
|
||||||
|
agent { label 'data' }
|
||||||
|
options { timeout(time: 30, unit: 'MINUTES') }
|
||||||
|
|
||||||
|
steps {
|
||||||
|
script {
|
||||||
|
def image = docker.build("springci/spring-data-with-mongodb-6.0:${p['java.main.tag']}", "--build-arg BASE=${p['docker.java.main.image']} --build-arg MONGODB=${p['docker.mongodb.6.0.version']} ci/openjdk17-mongodb-6.0/")
|
||||||
|
docker.withRegistry(p['docker.registry'], p['docker.credentials']) {
|
||||||
|
image.push()
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -100,7 +119,7 @@ pipeline {
|
|||||||
}
|
}
|
||||||
parallel {
|
parallel {
|
||||||
|
|
||||||
stage("test: mongodb 5.0 (Java 17)") {
|
stage("test: MongoDB 5.0 (Java 17)") {
|
||||||
agent {
|
agent {
|
||||||
label 'data'
|
label 'data'
|
||||||
}
|
}
|
||||||
@@ -121,6 +140,28 @@ pipeline {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
stage("test: MongoDB 6.0 (Java 17)") {
|
||||||
|
agent {
|
||||||
|
label 'data'
|
||||||
|
}
|
||||||
|
options { timeout(time: 30, unit: 'MINUTES') }
|
||||||
|
environment {
|
||||||
|
ARTIFACTORY = credentials("${p['artifactory.credentials']}")
|
||||||
|
}
|
||||||
|
steps {
|
||||||
|
script {
|
||||||
|
docker.image("harbor-repo.vmware.com/dockerhub-proxy-cache/springci/spring-data-with-mongodb-6.0:${p['java.main.tag']}").inside(p['docker.java.inside.basic']) {
|
||||||
|
sh 'mkdir -p /tmp/mongodb/db /tmp/mongodb/log'
|
||||||
|
sh 'mongod --setParameter transactionLifetimeLimitSeconds=90 --setParameter maxTransactionLockRequestTimeoutMillis=10000 --dbpath /tmp/mongodb/db --replSet rs0 --fork --logpath /tmp/mongodb/log/mongod.log &'
|
||||||
|
sh 'sleep 10'
|
||||||
|
sh 'mongosh --eval "rs.initiate({_id: \'rs0\', members:[{_id: 0, host: \'127.0.0.1:27017\'}]});"'
|
||||||
|
sh 'sleep 15'
|
||||||
|
sh 'MAVEN_OPTS="-Duser.name=jenkins -Duser.home=/tmp/jenkins-home" ./mvnw -s settings.xml clean dependency:list test -Duser.name=jenkins -Dsort -U -B'
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
147
README.adoc
147
README.adoc
@@ -93,142 +93,11 @@ and declare the appropriate dependency version.
|
|||||||
</repository>
|
</repository>
|
||||||
----
|
----
|
||||||
|
|
||||||
== Upgrading from 2.x
|
[[upgrading]]
|
||||||
|
== Upgrading
|
||||||
|
|
||||||
The 4.0 MongoDB Java Driver does no longer support certain features that have already been deprecated in one of the last minor versions.
|
Instructions for how to upgrade from earlier versions of Spring Data are provided on the project https://github.com/spring-projects/spring-data-commons/wiki[wiki].
|
||||||
Some of the changes affect the initial setup configuration as well as compile/runtime features. We summarized the most typical changes one might encounter.
|
Follow the links in the https://github.com/spring-projects/spring-data-commons/wiki#release-notes[release notes section] to find the version that you want to upgrade to.
|
||||||
|
|
||||||
=== XML Namespace
|
|
||||||
|
|
||||||
.Changed XML Namespace Elements and Attributes:
|
|
||||||
|===
|
|
||||||
| Element / Attribute | 2.x | 3.x
|
|
||||||
|
|
||||||
| `<mongo:mongo-client />`
|
|
||||||
| Used to create a `com.mongodb.MongoClient`
|
|
||||||
| Now exposes a `com.mongodb.client.MongoClient`
|
|
||||||
|
|
||||||
| `<mongo:mongo-client replica-set="..." />`
|
|
||||||
| Was a comma delimited list of replica set members (host/port)
|
|
||||||
| Now defines the replica set name. +
|
|
||||||
Use `<mongo:client-settings cluster-hosts="..." />` instead
|
|
||||||
|
|
||||||
| `<mongo:db-factory writeConcern="..." />`
|
|
||||||
| NONE, NORMAL, SAFE, FSYNC_SAFE, REPLICAS_SAFE, MAJORITY
|
|
||||||
| W1, W2, W3, UNAKNOWLEDGED, AKNOWLEDGED, JOURNALED, MAJORITY
|
|
||||||
|===
|
|
||||||
|
|
||||||
.Removed XML Namespace Elements and Attributes:
|
|
||||||
|===
|
|
||||||
| Element / Attribute | Replacement in 3.x | Comment
|
|
||||||
|
|
||||||
| `<mongo:db-factory mongo-ref="..." />`
|
|
||||||
| `<mongo:db-factory mongo-client-ref="..." />`
|
|
||||||
| Referencing a `com.mongodb.client.MongoClient`.
|
|
||||||
|
|
||||||
| `<mongo:mongo-client credentials="..." />`
|
|
||||||
| `<mongo:mongo-client credential="..." />`
|
|
||||||
| Single authentication data instead of list.
|
|
||||||
|
|
||||||
| `<mongo:client-options />`
|
|
||||||
| `<mongo:client-settings />`
|
|
||||||
| See `com.mongodb.MongoClientSettings` for details.
|
|
||||||
|===
|
|
||||||
|
|
||||||
.New XML Namespace Elements and Attributes:
|
|
||||||
|===
|
|
||||||
| Element | Comment
|
|
||||||
|
|
||||||
| `<mongo:db-factory mongo-client-ref="..." />`
|
|
||||||
| Replacement for `<mongo:db-factory mongo-ref="..." />`
|
|
||||||
|
|
||||||
| `<mongo:db-factory connection-string="..." />`
|
|
||||||
| Replacement for `uri` and `client-uri`.
|
|
||||||
|
|
||||||
| `<mongo:mongo-client connection-string="..." />`
|
|
||||||
| Replacement for `uri` and `client-uri`.
|
|
||||||
|
|
||||||
| `<mongo:client-settings />`
|
|
||||||
| Namespace element for `com.mongodb.MongoClientSettings`.
|
|
||||||
|
|
||||||
|===
|
|
||||||
|
|
||||||
=== Java Configuration
|
|
||||||
|
|
||||||
.Java API changes
|
|
||||||
|===
|
|
||||||
| Type | Comment
|
|
||||||
|
|
||||||
| `MongoClientFactoryBean`
|
|
||||||
| Creates `com.mongodb.client.MongoClient` instead of `com.mongodb.MongoClient` +
|
|
||||||
Uses `MongoClientSettings` instead of `MongoClientOptions`.
|
|
||||||
|
|
||||||
| `MongoDataIntegrityViolationException`
|
|
||||||
| Uses `WriteConcernResult` instead of `WriteResult`.
|
|
||||||
|
|
||||||
| `BulkOperationException`
|
|
||||||
| Uses `MongoBulkWriteException` and `com.mongodb.bulk.BulkWriteError` instead of `BulkWriteException` and `com.mongodb.BulkWriteError`
|
|
||||||
|
|
||||||
| `ReactiveMongoClientFactoryBean`
|
|
||||||
| Uses `com.mongodb.MongoClientSettings` instead of `com.mongodb.async.client.MongoClientSettings`
|
|
||||||
|
|
||||||
| `ReactiveMongoClientSettingsFactoryBean`
|
|
||||||
| Now produces `com.mongodb.MongoClientSettings` instead of `com.mongodb.async.client.MongoClientSettings`
|
|
||||||
|===
|
|
||||||
|
|
||||||
.Removed Java API:
|
|
||||||
|===
|
|
||||||
| 2.x | Replacement in 3.x | Comment
|
|
||||||
|
|
||||||
| `MongoClientOptionsFactoryBean`
|
|
||||||
| `MongoClientSettingsFactoryBean`
|
|
||||||
| Creating a `com.mongodb.MongoClientSettings`.
|
|
||||||
|
|
||||||
| `AbstractMongoConfiguration`
|
|
||||||
| `AbstractMongoClientConfiguration` +
|
|
||||||
(Available since 2.1)
|
|
||||||
| Using `com.mongodb.client.MongoClient`.
|
|
||||||
|
|
||||||
| `MongoDbFactory#getLegacyDb()`
|
|
||||||
| -
|
|
||||||
| -
|
|
||||||
|
|
||||||
| `SimpleMongoDbFactory`
|
|
||||||
| `SimpleMongoClientDbFactory` +
|
|
||||||
(Available since 2.1)
|
|
||||||
|
|
|
||||||
|
|
||||||
| `MapReduceOptions#getOutputType()`
|
|
||||||
| `MapReduceOptions#getMapReduceAction()`
|
|
||||||
| Returns `MapReduceAction` instead of `MapReduceCommand.OutputType`.
|
|
||||||
|
|
||||||
| `Meta\|Query` maxScan & snapshot
|
|
||||||
|
|
|
||||||
|
|
|
||||||
|===
|
|
||||||
|
|
||||||
=== Other Changes
|
|
||||||
|
|
||||||
==== UUID Types
|
|
||||||
|
|
||||||
The MongoDB UUID representation can now be configured with different formats.
|
|
||||||
This has to be done via `MongoClientSettings` as shown in the snippet below.
|
|
||||||
|
|
||||||
.UUID Codec Configuration
|
|
||||||
====
|
|
||||||
[source,java]
|
|
||||||
----
|
|
||||||
static class Config extends AbstractMongoClientConfiguration {
|
|
||||||
|
|
||||||
@Override
|
|
||||||
public void configureClientSettings(MongoClientSettings.Builder builder) {
|
|
||||||
builder.uuidRepresentation(UuidRepresentation.STANDARD);
|
|
||||||
}
|
|
||||||
|
|
||||||
// ...
|
|
||||||
}
|
|
||||||
----
|
|
||||||
====
|
|
||||||
|
|
||||||
[[getting-help]]
|
[[getting-help]]
|
||||||
== Getting Help
|
== Getting Help
|
||||||
@@ -277,8 +146,8 @@ and accessible from Maven using the Maven configuration noted <<maven-configurat
|
|||||||
NOTE: Configuration for Gradle is similar to Maven.
|
NOTE: Configuration for Gradle is similar to Maven.
|
||||||
|
|
||||||
The best way to get started is by creating a Spring Boot project using MongoDB on https://start.spring.io[start.spring.io].
|
The best way to get started is by creating a Spring Boot project using MongoDB on https://start.spring.io[start.spring.io].
|
||||||
Follow this https://start.spring.io/#type=maven-project&language=java&platformVersion=2.5.4&packaging=jar&jvmVersion=1.8&groupId=com.example&artifactId=demo&name=demo&description=Demo%20project%20for%20Spring%20Boot&packageName=com.example.demo&dependencies=data-mongodb[link]
|
Follow this https://start.spring.io/#type=maven-project&language=java&platformVersion=3.0.0&packaging=jar&jvmVersion=17&groupId=com.example&artifactId=demo&name=demo&description=Demo%20project%20for%20Spring%20Boot&packageName=com.example.demo&dependencies=data-mongodb[link]
|
||||||
to build an imperative application and this https://start.spring.io/#type=maven-project&language=java&platformVersion=2.5.4&packaging=jar&jvmVersion=1.8&groupId=com.example&artifactId=demo&name=demo&description=Demo%20project%20for%20Spring%20Boot&packageName=com.example.demo&dependencies=data-mongodb-reactive[link]
|
to build an imperative application and this https://start.spring.io/#type=maven-project&language=java&platformVersion=3.0.0&packaging=jar&jvmVersion=17&groupId=com.example&artifactId=demo&name=demo&description=Demo%20project%20for%20Spring%20Boot&packageName=com.example.demo&dependencies=data-mongodb-reactive[link]
|
||||||
to build a reactive one.
|
to build a reactive one.
|
||||||
|
|
||||||
However, if you want to try out the latest and greatest, Spring Data MongoDB can be easily built with the https://github.com/takari/maven-wrapper[Maven wrapper]
|
However, if you want to try out the latest and greatest, Spring Data MongoDB can be easily built with the https://github.com/takari/maven-wrapper[Maven wrapper]
|
||||||
@@ -313,7 +182,7 @@ To initialize the replica set, start a mongo client:
|
|||||||
[source,bash]
|
[source,bash]
|
||||||
----
|
----
|
||||||
$ $MONGODB_HOME/bin/mongo
|
$ $MONGODB_HOME/bin/mongo
|
||||||
MongoDB server version: 5.0.0
|
MongoDB server version: 6.0.0
|
||||||
...
|
...
|
||||||
----
|
----
|
||||||
|
|
||||||
@@ -341,7 +210,7 @@ Now you are ready to build Spring Data MongoDB. Simply enter the following `mvnw
|
|||||||
$ ./mvnw clean install
|
$ ./mvnw clean install
|
||||||
----
|
----
|
||||||
|
|
||||||
If you want to build with the regular `mvn` command, you will need https://maven.apache.org/run-maven/index.html[Maven v3.5.0 or above].
|
If you want to build with the regular `mvn` command, you will need https://maven.apache.org/run-maven/index.html[Maven v3.8.0 or above].
|
||||||
|
|
||||||
_Also see link:CONTRIBUTING.adoc[CONTRIBUTING.adoc] if you wish to submit pull requests, and in particular, please sign
|
_Also see link:CONTRIBUTING.adoc[CONTRIBUTING.adoc] if you wish to submit pull requests, and in particular, please sign
|
||||||
the https://cla.pivotal.io/sign/spring[Contributor’s Agreement] before your first non-trivial change._
|
the https://cla.pivotal.io/sign/spring[Contributor’s Agreement] before your first non-trivial change._
|
||||||
|
|||||||
@@ -7,15 +7,16 @@ ENV TZ=Etc/UTC
|
|||||||
ENV DEBIAN_FRONTEND=noninteractive
|
ENV DEBIAN_FRONTEND=noninteractive
|
||||||
|
|
||||||
RUN set -eux; \
|
RUN set -eux; \
|
||||||
sed -i -e 's/archive.ubuntu.com/mirror.one.com/g' /etc/apt/sources.list; \
|
sed -i -e 's/archive.ubuntu.com/mirror.one.com/g' /etc/apt/sources.list && \
|
||||||
sed -i -e 's/security.ubuntu.com/mirror.one.com/g' /etc/apt/sources.list; \
|
sed -i -e 's/security.ubuntu.com/mirror.one.com/g' /etc/apt/sources.list && \
|
||||||
sed -i -e 's/http/https/g' /etc/apt/sources.list ; \
|
sed -i -e 's/ports.ubuntu.com/mirrors.ocf.berkeley.edu/g' /etc/apt/sources.list && \
|
||||||
apt-get update && apt-get install -y apt-transport-https apt-utils gnupg2 ; \
|
sed -i -e 's/http/https/g' /etc/apt/sources.list && \
|
||||||
apt-key adv --keyserver hkps://keyserver.ubuntu.com:443 --recv 656408E390CFB1F5 ; \
|
apt-get update && apt-get install -y apt-transport-https apt-utils gnupg2 && \
|
||||||
echo "deb [ arch=amd64 ] https://repo.mongodb.org/apt/ubuntu bionic/mongodb-org/4.4 multiverse" | tee /etc/apt/sources.list.d/mongodb-org-4.4.list; \
|
apt-key adv --keyserver hkps://keyserver.ubuntu.com:443 --recv 656408E390CFB1F5 && \
|
||||||
echo ${TZ} > /etc/timezone;
|
echo "deb [ arch=amd64,arm64 ] https://repo.mongodb.org/apt/ubuntu focal/mongodb-org/4.4 multiverse" | tee /etc/apt/sources.list.d/mongodb-org-4.4.list && \
|
||||||
|
echo ${TZ} > /etc/timezone
|
||||||
|
|
||||||
RUN apt-get update ; \
|
RUN apt-get update && \
|
||||||
apt-get install -y mongodb-org=${MONGODB} mongodb-org-server=${MONGODB} mongodb-org-shell=${MONGODB} mongodb-org-mongos=${MONGODB} mongodb-org-tools=${MONGODB} ; \
|
apt-get install -y mongodb-org=${MONGODB} mongodb-org-server=${MONGODB} mongodb-org-shell=${MONGODB} mongodb-org-mongos=${MONGODB} mongodb-org-tools=${MONGODB} && \
|
||||||
apt-get clean; \
|
apt-get clean && \
|
||||||
rm -rf /var/lib/apt/lists/*;
|
rm -rf /var/lib/apt/lists/*
|
||||||
|
|||||||
@@ -7,17 +7,18 @@ ENV TZ=Etc/UTC
|
|||||||
ENV DEBIAN_FRONTEND=noninteractive
|
ENV DEBIAN_FRONTEND=noninteractive
|
||||||
|
|
||||||
RUN set -eux; \
|
RUN set -eux; \
|
||||||
sed -i -e 's/archive.ubuntu.com/mirror.one.com/g' /etc/apt/sources.list; \
|
sed -i -e 's/archive.ubuntu.com/mirror.one.com/g' /etc/apt/sources.list && \
|
||||||
sed -i -e 's/security.ubuntu.com/mirror.one.com/g' /etc/apt/sources.list; \
|
sed -i -e 's/security.ubuntu.com/mirror.one.com/g' /etc/apt/sources.list && \
|
||||||
sed -i -e 's/http/https/g' /etc/apt/sources.list ; \
|
sed -i -e 's/ports.ubuntu.com/mirrors.ocf.berkeley.edu/g' /etc/apt/sources.list && \
|
||||||
apt-get update && apt-get install -y apt-transport-https apt-utils gnupg2 wget ; \
|
sed -i -e 's/http/https/g' /etc/apt/sources.list && \
|
||||||
|
apt-get update && apt-get install -y apt-transport-https apt-utils gnupg2 wget && \
|
||||||
# MongoDB 5.0 release signing key
|
# MongoDB 5.0 release signing key
|
||||||
apt-key adv --keyserver hkps://keyserver.ubuntu.com:443 --recv B00A0BD1E2C63C11 ; \
|
apt-key adv --keyserver hkps://keyserver.ubuntu.com:443 --recv B00A0BD1E2C63C11 && \
|
||||||
# Needed when MongoDB creates a 5.0 folder.
|
# Needed when MongoDB creates a 5.0 folder.
|
||||||
echo "deb [ arch=amd64 ] https://repo.mongodb.org/apt/ubuntu bionic/mongodb-org/5.0 multiverse" | tee /etc/apt/sources.list.d/mongodb-org-5.0.list; \
|
echo "deb [ arch=amd64,arm64 ] https://repo.mongodb.org/apt/ubuntu focal/mongodb-org/5.0 multiverse" | tee /etc/apt/sources.list.d/mongodb-org-5.0.list && \
|
||||||
echo ${TZ} > /etc/timezone;
|
echo ${TZ} > /etc/timezone
|
||||||
|
|
||||||
RUN apt-get update; \
|
RUN apt-get update && \
|
||||||
apt-get install -y mongodb-org=${MONGODB} mongodb-org-server=${MONGODB} mongodb-org-shell=${MONGODB} mongodb-org-mongos=${MONGODB} mongodb-org-tools=${MONGODB} ; \
|
apt-get install -y mongodb-org=${MONGODB} mongodb-org-server=${MONGODB} mongodb-org-shell=${MONGODB} mongodb-org-mongos=${MONGODB} mongodb-org-tools=${MONGODB} && \
|
||||||
apt-get clean; \
|
apt-get clean && \
|
||||||
rm -rf /var/lib/apt/lists/*;
|
rm -rf /var/lib/apt/lists/*
|
||||||
|
|||||||
24
ci/openjdk17-mongodb-6.0/Dockerfile
Normal file
24
ci/openjdk17-mongodb-6.0/Dockerfile
Normal file
@@ -0,0 +1,24 @@
|
|||||||
|
ARG BASE
|
||||||
|
FROM ${BASE}
|
||||||
|
# Any ARG statements before FROM are cleared.
|
||||||
|
ARG MONGODB
|
||||||
|
|
||||||
|
ENV TZ=Etc/UTC
|
||||||
|
ENV DEBIAN_FRONTEND=noninteractive
|
||||||
|
|
||||||
|
RUN set -eux; \
|
||||||
|
sed -i -e 's/archive.ubuntu.com/mirror.one.com/g' /etc/apt/sources.list && \
|
||||||
|
sed -i -e 's/security.ubuntu.com/mirror.one.com/g' /etc/apt/sources.list && \
|
||||||
|
sed -i -e 's/ports.ubuntu.com/mirrors.ocf.berkeley.edu/g' /etc/apt/sources.list && \
|
||||||
|
sed -i -e 's/http/https/g' /etc/apt/sources.list && \
|
||||||
|
apt-get update && apt-get install -y apt-transport-https apt-utils gnupg2 wget && \
|
||||||
|
# MongoDB 6.0 release signing key
|
||||||
|
wget -qO - https://www.mongodb.org/static/pgp/server-6.0.asc | apt-key add - && \
|
||||||
|
# Needed when MongoDB creates a 6.0 folder.
|
||||||
|
echo "deb [ arch=amd64,arm64 ] https://repo.mongodb.org/apt/ubuntu focal/mongodb-org/6.0 multiverse" | tee /etc/apt/sources.list.d/mongodb-org-6.0.list && \
|
||||||
|
echo ${TZ} > /etc/timezone
|
||||||
|
|
||||||
|
RUN apt-get update && \
|
||||||
|
apt-get install -y mongodb-org=${MONGODB} mongodb-org-server=${MONGODB} mongodb-org-shell=${MONGODB} mongodb-org-mongos=${MONGODB} mongodb-org-tools=${MONGODB} && \
|
||||||
|
apt-get clean && \
|
||||||
|
rm -rf /var/lib/apt/lists/*
|
||||||
@@ -1,18 +1,19 @@
|
|||||||
# Java versions
|
# Java versions
|
||||||
java.main.tag=17.0.2_8-jdk
|
java.main.tag=17.0.6_10-jdk-focal
|
||||||
|
|
||||||
# Docker container images - standard
|
# Docker container images - standard
|
||||||
docker.java.main.image=harbor-repo.vmware.com/dockerhub-proxy-cache/library/eclipse-temurin:${java.main.tag}
|
docker.java.main.image=harbor-repo.vmware.com/dockerhub-proxy-cache/library/eclipse-temurin:${java.main.tag}
|
||||||
|
|
||||||
# Supported versions of MongoDB
|
# Supported versions of MongoDB
|
||||||
docker.mongodb.4.4.version=4.4.12
|
docker.mongodb.4.4.version=4.4.18
|
||||||
docker.mongodb.5.0.version=5.0.6
|
docker.mongodb.5.0.version=5.0.14
|
||||||
|
docker.mongodb.6.0.version=6.0.4
|
||||||
|
|
||||||
# Supported versions of Redis
|
# Supported versions of Redis
|
||||||
docker.redis.6.version=6.2.6
|
docker.redis.6.version=6.2.10
|
||||||
|
|
||||||
# Supported versions of Cassandra
|
# Supported versions of Cassandra
|
||||||
docker.cassandra.3.version=3.11.12
|
docker.cassandra.3.version=3.11.14
|
||||||
|
|
||||||
# Docker environment settings
|
# Docker environment settings
|
||||||
docker.java.inside.basic=-v $HOME:/tmp/jenkins-home
|
docker.java.inside.basic=-v $HOME:/tmp/jenkins-home
|
||||||
|
|||||||
12
pom.xml
12
pom.xml
@@ -5,7 +5,7 @@
|
|||||||
|
|
||||||
<groupId>org.springframework.data</groupId>
|
<groupId>org.springframework.data</groupId>
|
||||||
<artifactId>spring-data-mongodb-parent</artifactId>
|
<artifactId>spring-data-mongodb-parent</artifactId>
|
||||||
<version>4.0.0-M5</version>
|
<version>4.1.0-archunit-dependency-tests-SNAPSHOT</version>
|
||||||
<packaging>pom</packaging>
|
<packaging>pom</packaging>
|
||||||
|
|
||||||
<name>Spring Data MongoDB</name>
|
<name>Spring Data MongoDB</name>
|
||||||
@@ -15,7 +15,7 @@
|
|||||||
<parent>
|
<parent>
|
||||||
<groupId>org.springframework.data.build</groupId>
|
<groupId>org.springframework.data.build</groupId>
|
||||||
<artifactId>spring-data-parent</artifactId>
|
<artifactId>spring-data-parent</artifactId>
|
||||||
<version>3.0.0-M5</version>
|
<version>3.1.0-SNAPSHOT</version>
|
||||||
</parent>
|
</parent>
|
||||||
|
|
||||||
<modules>
|
<modules>
|
||||||
@@ -26,8 +26,8 @@
|
|||||||
<properties>
|
<properties>
|
||||||
<project.type>multi</project.type>
|
<project.type>multi</project.type>
|
||||||
<dist.id>spring-data-mongodb</dist.id>
|
<dist.id>spring-data-mongodb</dist.id>
|
||||||
<springdata.commons>3.0.0-M5</springdata.commons>
|
<springdata.commons>3.1.0-SNAPSHOT</springdata.commons>
|
||||||
<mongo>4.7.0-beta0</mongo>
|
<mongo>4.9.0</mongo>
|
||||||
<mongo.reactivestreams>${mongo}</mongo.reactivestreams>
|
<mongo.reactivestreams>${mongo}</mongo.reactivestreams>
|
||||||
<jmh.version>1.19</jmh.version>
|
<jmh.version>1.19</jmh.version>
|
||||||
</properties>
|
</properties>
|
||||||
@@ -145,8 +145,8 @@
|
|||||||
|
|
||||||
<repositories>
|
<repositories>
|
||||||
<repository>
|
<repository>
|
||||||
<id>spring-libs-milestone</id>
|
<id>spring-libs-snapshot</id>
|
||||||
<url>https://repo.spring.io/libs-milestone</url>
|
<url>https://repo.spring.io/libs-snapshot</url>
|
||||||
<snapshots>
|
<snapshots>
|
||||||
<enabled>true</enabled>
|
<enabled>true</enabled>
|
||||||
</snapshots>
|
</snapshots>
|
||||||
|
|||||||
@@ -7,7 +7,7 @@
|
|||||||
<parent>
|
<parent>
|
||||||
<groupId>org.springframework.data</groupId>
|
<groupId>org.springframework.data</groupId>
|
||||||
<artifactId>spring-data-mongodb-parent</artifactId>
|
<artifactId>spring-data-mongodb-parent</artifactId>
|
||||||
<version>4.0.0-M5</version>
|
<version>4.1.0-archunit-dependency-tests-SNAPSHOT</version>
|
||||||
<relativePath>../pom.xml</relativePath>
|
<relativePath>../pom.xml</relativePath>
|
||||||
</parent>
|
</parent>
|
||||||
|
|
||||||
|
|||||||
@@ -1,5 +1,5 @@
|
|||||||
/*
|
/*
|
||||||
* Copyright 2017-2022 the original author or authors.
|
* Copyright 2017-2023 the original author or authors.
|
||||||
*
|
*
|
||||||
* Licensed under the Apache License, Version 2.0 (the "License");
|
* Licensed under the Apache License, Version 2.0 (the "License");
|
||||||
* you may not use this file except in compliance with the License.
|
* you may not use this file except in compliance with the License.
|
||||||
|
|||||||
@@ -1,5 +1,5 @@
|
|||||||
/*
|
/*
|
||||||
* Copyright 2017-2022 the original author or authors.
|
* Copyright 2017-2023 the original author or authors.
|
||||||
*
|
*
|
||||||
* Licensed under the Apache License, Version 2.0 (the "License");
|
* Licensed under the Apache License, Version 2.0 (the "License");
|
||||||
* you may not use this file except in compliance with the License.
|
* you may not use this file except in compliance with the License.
|
||||||
|
|||||||
@@ -1,5 +1,5 @@
|
|||||||
/*
|
/*
|
||||||
* Copyright 2017-2022 the original author or authors.
|
* Copyright 2017-2023 the original author or authors.
|
||||||
*
|
*
|
||||||
* Licensed under the Apache License, Version 2.0 (the "License");
|
* Licensed under the Apache License, Version 2.0 (the "License");
|
||||||
* you may not use this file except in compliance with the License.
|
* you may not use this file except in compliance with the License.
|
||||||
|
|||||||
@@ -1,5 +1,5 @@
|
|||||||
/*
|
/*
|
||||||
* Copyright 2017-2022 the original author or authors.
|
* Copyright 2017-2023 the original author or authors.
|
||||||
*
|
*
|
||||||
* Licensed under the Apache License, Version 2.0 (the "License");
|
* Licensed under the Apache License, Version 2.0 (the "License");
|
||||||
* you may not use this file except in compliance with the License.
|
* you may not use this file except in compliance with the License.
|
||||||
|
|||||||
@@ -1,5 +1,5 @@
|
|||||||
/*
|
/*
|
||||||
* Copyright 2017-2022 the original author or authors.
|
* Copyright 2017-2023 the original author or authors.
|
||||||
*
|
*
|
||||||
* Licensed under the Apache License, Version 2.0 (the "License");
|
* Licensed under the Apache License, Version 2.0 (the "License");
|
||||||
* you may not use this file except in compliance with the License.
|
* you may not use this file except in compliance with the License.
|
||||||
|
|||||||
@@ -1,5 +1,5 @@
|
|||||||
/*
|
/*
|
||||||
* Copyright 2017-2022 the original author or authors.
|
* Copyright 2017-2023 the original author or authors.
|
||||||
*
|
*
|
||||||
* Licensed under the Apache License, Version 2.0 (the "License");
|
* Licensed under the Apache License, Version 2.0 (the "License");
|
||||||
* you may not use this file except in compliance with the License.
|
* you may not use this file except in compliance with the License.
|
||||||
|
|||||||
@@ -1,5 +1,5 @@
|
|||||||
/*
|
/*
|
||||||
* Copyright 2017-2022 the original author or authors.
|
* Copyright 2017-2023 the original author or authors.
|
||||||
*
|
*
|
||||||
* Licensed under the Apache License, Version 2.0 (the "License");
|
* Licensed under the Apache License, Version 2.0 (the "License");
|
||||||
* you may not use this file except in compliance with the License.
|
* you may not use this file except in compliance with the License.
|
||||||
|
|||||||
@@ -15,18 +15,13 @@
|
|||||||
<parent>
|
<parent>
|
||||||
<groupId>org.springframework.data</groupId>
|
<groupId>org.springframework.data</groupId>
|
||||||
<artifactId>spring-data-mongodb-parent</artifactId>
|
<artifactId>spring-data-mongodb-parent</artifactId>
|
||||||
<version>4.0.0-M5</version>
|
<version>4.1.0-archunit-dependency-tests-SNAPSHOT</version>
|
||||||
<relativePath>../pom.xml</relativePath>
|
<relativePath>../pom.xml</relativePath>
|
||||||
</parent>
|
</parent>
|
||||||
|
|
||||||
<properties>
|
<properties>
|
||||||
<project.root>${basedir}/..</project.root>
|
<project.root>${basedir}/..</project.root>
|
||||||
<dist.key>SDMONGO</dist.key>
|
<dist.key>SDMONGO</dist.key>
|
||||||
|
|
||||||
<!-- Observability -->
|
|
||||||
<micrometer-docs-generator.inputPath>${maven.multiModuleProjectDirectory}/spring-data-mongodb/</micrometer-docs-generator.inputPath>
|
|
||||||
<micrometer-docs-generator.inclusionPattern>.*</micrometer-docs-generator.inclusionPattern>
|
|
||||||
<micrometer-docs-generator.outputPath>${maven.multiModuleProjectDirectory}/target/</micrometer-docs-generator.outputPath>
|
|
||||||
</properties>
|
</properties>
|
||||||
|
|
||||||
<build>
|
<build>
|
||||||
@@ -35,56 +30,6 @@
|
|||||||
<groupId>org.apache.maven.plugins</groupId>
|
<groupId>org.apache.maven.plugins</groupId>
|
||||||
<artifactId>maven-assembly-plugin</artifactId>
|
<artifactId>maven-assembly-plugin</artifactId>
|
||||||
</plugin>
|
</plugin>
|
||||||
<plugin>
|
|
||||||
<groupId>org.codehaus.mojo</groupId>
|
|
||||||
<artifactId>exec-maven-plugin</artifactId>
|
|
||||||
<executions>
|
|
||||||
<execution>
|
|
||||||
<id>generate-metrics-metadata</id>
|
|
||||||
<phase>prepare-package</phase>
|
|
||||||
<goals>
|
|
||||||
<goal>java</goal>
|
|
||||||
</goals>
|
|
||||||
<configuration>
|
|
||||||
<mainClass>io.micrometer.docs.metrics.DocsFromSources
|
|
||||||
</mainClass>
|
|
||||||
</configuration>
|
|
||||||
</execution>
|
|
||||||
<execution>
|
|
||||||
<id>generate-tracing-metadata</id>
|
|
||||||
<phase>prepare-package</phase>
|
|
||||||
<goals>
|
|
||||||
<goal>java</goal>
|
|
||||||
</goals>
|
|
||||||
<configuration>
|
|
||||||
<mainClass>io.micrometer.docs.spans.DocsFromSources
|
|
||||||
</mainClass>
|
|
||||||
</configuration>
|
|
||||||
</execution>
|
|
||||||
</executions>
|
|
||||||
<dependencies>
|
|
||||||
<dependency>
|
|
||||||
<groupId>io.micrometer</groupId>
|
|
||||||
<artifactId>micrometer-docs-generator-spans</artifactId>
|
|
||||||
<version>${micrometer-docs-generator}</version>
|
|
||||||
<type>jar</type>
|
|
||||||
</dependency>
|
|
||||||
<dependency>
|
|
||||||
<groupId>io.micrometer</groupId>
|
|
||||||
<artifactId>micrometer-docs-generator-metrics</artifactId>
|
|
||||||
<version>${micrometer-docs-generator}</version>
|
|
||||||
<type>jar</type>
|
|
||||||
</dependency>
|
|
||||||
</dependencies>
|
|
||||||
<configuration>
|
|
||||||
<includePluginDependencies>true</includePluginDependencies>
|
|
||||||
<arguments>
|
|
||||||
<argument>${micrometer-docs-generator.inputPath}</argument>
|
|
||||||
<argument>${micrometer-docs-generator.inclusionPattern}</argument>
|
|
||||||
<argument>${micrometer-docs-generator.outputPath}</argument>
|
|
||||||
</arguments>
|
|
||||||
</configuration>
|
|
||||||
</plugin>
|
|
||||||
<plugin>
|
<plugin>
|
||||||
<groupId>org.asciidoctor</groupId>
|
<groupId>org.asciidoctor</groupId>
|
||||||
<artifactId>asciidoctor-maven-plugin</artifactId>
|
<artifactId>asciidoctor-maven-plugin</artifactId>
|
||||||
@@ -100,4 +45,15 @@
|
|||||||
|
|
||||||
</build>
|
</build>
|
||||||
|
|
||||||
|
<pluginRepositories>
|
||||||
|
<pluginRepository>
|
||||||
|
<id>spring-plugins-release</id>
|
||||||
|
<url>https://repo.spring.io/plugins-release</url>
|
||||||
|
</pluginRepository>
|
||||||
|
<pluginRepository>
|
||||||
|
<id>spring-plugins-snapshot</id>
|
||||||
|
<url>https://repo.spring.io/libs-snapshot</url>
|
||||||
|
</pluginRepository>
|
||||||
|
</pluginRepositories>
|
||||||
|
|
||||||
</project>
|
</project>
|
||||||
|
|||||||
@@ -1,5 +1,6 @@
|
|||||||
<?xml version="1.0" encoding="UTF-8"?>
|
<?xml version="1.0" encoding="UTF-8"?>
|
||||||
<project xmlns="http://maven.apache.org/POM/4.0.0" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
|
<project xmlns="http://maven.apache.org/POM/4.0.0"
|
||||||
|
xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
|
||||||
xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 https://maven.apache.org/xsd/maven-4.0.0.xsd">
|
xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 https://maven.apache.org/xsd/maven-4.0.0.xsd">
|
||||||
|
|
||||||
<modelVersion>4.0.0</modelVersion>
|
<modelVersion>4.0.0</modelVersion>
|
||||||
@@ -12,7 +13,7 @@
|
|||||||
<parent>
|
<parent>
|
||||||
<groupId>org.springframework.data</groupId>
|
<groupId>org.springframework.data</groupId>
|
||||||
<artifactId>spring-data-mongodb-parent</artifactId>
|
<artifactId>spring-data-mongodb-parent</artifactId>
|
||||||
<version>4.0.0-M5</version>
|
<version>4.1.0-archunit-dependency-tests-SNAPSHOT</version>
|
||||||
<relativePath>../pom.xml</relativePath>
|
<relativePath>../pom.xml</relativePath>
|
||||||
</parent>
|
</parent>
|
||||||
|
|
||||||
@@ -22,6 +23,7 @@
|
|||||||
<java-module-name>spring.data.mongodb</java-module-name>
|
<java-module-name>spring.data.mongodb</java-module-name>
|
||||||
<project.root>${basedir}/..</project.root>
|
<project.root>${basedir}/..</project.root>
|
||||||
<multithreadedtc>1.01</multithreadedtc>
|
<multithreadedtc>1.01</multithreadedtc>
|
||||||
|
<archunit.version>1.0.1</archunit.version>
|
||||||
</properties>
|
</properties>
|
||||||
|
|
||||||
<dependencies>
|
<dependencies>
|
||||||
@@ -249,9 +251,9 @@
|
|||||||
</dependency>
|
</dependency>
|
||||||
|
|
||||||
<dependency>
|
<dependency>
|
||||||
<groupId>de.schauderhaft.degraph</groupId>
|
<groupId>com.tngtech.archunit</groupId>
|
||||||
<artifactId>degraph-check</artifactId>
|
<artifactId>archunit</artifactId>
|
||||||
<version>0.1.4</version>
|
<version>${archunit.version}</version>
|
||||||
<scope>test</scope>
|
<scope>test</scope>
|
||||||
</dependency>
|
</dependency>
|
||||||
|
|
||||||
@@ -303,7 +305,7 @@
|
|||||||
|
|
||||||
<dependency>
|
<dependency>
|
||||||
<groupId>io.mockk</groupId>
|
<groupId>io.mockk</groupId>
|
||||||
<artifactId>mockk</artifactId>
|
<artifactId>mockk-jvm</artifactId>
|
||||||
<version>${mockk}</version>
|
<version>${mockk}</version>
|
||||||
<scope>test</scope>
|
<scope>test</scope>
|
||||||
</dependency>
|
</dependency>
|
||||||
@@ -312,6 +314,12 @@
|
|||||||
<groupId>io.micrometer</groupId>
|
<groupId>io.micrometer</groupId>
|
||||||
<artifactId>micrometer-test</artifactId>
|
<artifactId>micrometer-test</artifactId>
|
||||||
<scope>test</scope>
|
<scope>test</scope>
|
||||||
|
<exclusions>
|
||||||
|
<exclusion>
|
||||||
|
<groupId>com.github.tomakehurst</groupId>
|
||||||
|
<artifactId>wiremock-jre8-standalone</artifactId>
|
||||||
|
</exclusion>
|
||||||
|
</exclusions>
|
||||||
</dependency>
|
</dependency>
|
||||||
<dependency>
|
<dependency>
|
||||||
<groupId>io.micrometer</groupId>
|
<groupId>io.micrometer</groupId>
|
||||||
@@ -358,8 +366,11 @@
|
|||||||
<goal>test-process</goal>
|
<goal>test-process</goal>
|
||||||
</goals>
|
</goals>
|
||||||
<configuration>
|
<configuration>
|
||||||
<outputDirectory>target/generated-test-sources</outputDirectory>
|
<outputDirectory>target/generated-test-sources
|
||||||
<processor>org.springframework.data.mongodb.repository.support.MongoAnnotationProcessor</processor>
|
</outputDirectory>
|
||||||
|
<processor>
|
||||||
|
org.springframework.data.mongodb.repository.support.MongoAnnotationProcessor
|
||||||
|
</processor>
|
||||||
</configuration>
|
</configuration>
|
||||||
</execution>
|
</execution>
|
||||||
</executions>
|
</executions>
|
||||||
@@ -379,7 +390,9 @@
|
|||||||
<exclude>**/ReactivePerformanceTests.java</exclude>
|
<exclude>**/ReactivePerformanceTests.java</exclude>
|
||||||
</excludes>
|
</excludes>
|
||||||
<systemPropertyVariables>
|
<systemPropertyVariables>
|
||||||
<java.util.logging.config.file>src/test/resources/logging.properties</java.util.logging.config.file>
|
<java.util.logging.config.file>
|
||||||
|
src/test/resources/logging.properties
|
||||||
|
</java.util.logging.config.file>
|
||||||
<reactor.trace.cancel>true</reactor.trace.cancel>
|
<reactor.trace.cancel>true</reactor.trace.cancel>
|
||||||
</systemPropertyVariables>
|
</systemPropertyVariables>
|
||||||
</configuration>
|
</configuration>
|
||||||
|
|||||||
@@ -1,5 +1,5 @@
|
|||||||
/*
|
/*
|
||||||
* Copyright 2021-2022 the original author or authors.
|
* Copyright 2021-2023 the original author or authors.
|
||||||
*
|
*
|
||||||
* Licensed under the Apache License, Version 2.0 (the "License");
|
* Licensed under the Apache License, Version 2.0 (the "License");
|
||||||
* you may not use this file except in compliance with the License.
|
* you may not use this file except in compliance with the License.
|
||||||
|
|||||||
@@ -1,5 +1,5 @@
|
|||||||
/*
|
/*
|
||||||
* Copyright 2015-2022 the original author or authors.
|
* Copyright 2015-2023 the original author or authors.
|
||||||
*
|
*
|
||||||
* Licensed under the Apache License, Version 2.0 (the "License");
|
* Licensed under the Apache License, Version 2.0 (the "License");
|
||||||
* you may not use this file except in compliance with the License.
|
* you may not use this file except in compliance with the License.
|
||||||
|
|||||||
@@ -1,5 +1,5 @@
|
|||||||
/*
|
/*
|
||||||
* Copyright 2018-2022 the original author or authors.
|
* Copyright 2018-2023 the original author or authors.
|
||||||
*
|
*
|
||||||
* Licensed under the Apache License, Version 2.0 (the "License");
|
* Licensed under the Apache License, Version 2.0 (the "License");
|
||||||
* you may not use this file except in compliance with the License.
|
* you may not use this file except in compliance with the License.
|
||||||
|
|||||||
@@ -1,5 +1,5 @@
|
|||||||
/*
|
/*
|
||||||
* Copyright 2017-2022 the original author or authors.
|
* Copyright 2017-2023 the original author or authors.
|
||||||
*
|
*
|
||||||
* Licensed under the Apache License, Version 2.0 (the "License");
|
* Licensed under the Apache License, Version 2.0 (the "License");
|
||||||
* you may not use this file except in compliance with the License.
|
* you may not use this file except in compliance with the License.
|
||||||
|
|||||||
@@ -1,5 +1,5 @@
|
|||||||
/*
|
/*
|
||||||
* Copyright 2010-2022 the original author or authors.
|
* Copyright 2010-2023 the original author or authors.
|
||||||
*
|
*
|
||||||
* Licensed under the Apache License, Version 2.0 (the "License");
|
* Licensed under the Apache License, Version 2.0 (the "License");
|
||||||
* you may not use this file except in compliance with the License.
|
* you may not use this file except in compliance with the License.
|
||||||
|
|||||||
@@ -1,5 +1,5 @@
|
|||||||
/*
|
/*
|
||||||
* Copyright 2013-2022 the original author or authors.
|
* Copyright 2013-2023 the original author or authors.
|
||||||
*
|
*
|
||||||
* Licensed under the Apache License, Version 2.0 (the "License");
|
* Licensed under the Apache License, Version 2.0 (the "License");
|
||||||
* you may not use this file except in compliance with the License.
|
* you may not use this file except in compliance with the License.
|
||||||
|
|||||||
@@ -1,5 +1,5 @@
|
|||||||
/*
|
/*
|
||||||
* Copyright 2011-2022 the original author or authors.
|
* Copyright 2011-2023 the original author or authors.
|
||||||
*
|
*
|
||||||
* Licensed under the Apache License, Version 2.0 (the "License");
|
* Licensed under the Apache License, Version 2.0 (the "License");
|
||||||
* you may not use this file except in compliance with the License.
|
* you may not use this file except in compliance with the License.
|
||||||
|
|||||||
@@ -1,5 +1,5 @@
|
|||||||
/*
|
/*
|
||||||
* Copyright 2011-2022 the original author or authors.
|
* Copyright 2011-2023 the original author or authors.
|
||||||
*
|
*
|
||||||
* Licensed under the Apache License, Version 2.0 (the "License");
|
* Licensed under the Apache License, Version 2.0 (the "License");
|
||||||
* you may not use this file except in compliance with the License.
|
* you may not use this file except in compliance with the License.
|
||||||
|
|||||||
@@ -1,5 +1,5 @@
|
|||||||
/*
|
/*
|
||||||
* Copyright 2018-2022 the original author or authors.
|
* Copyright 2018-2023 the original author or authors.
|
||||||
*
|
*
|
||||||
* Licensed under the Apache License, Version 2.0 (the "License");
|
* Licensed under the Apache License, Version 2.0 (the "License");
|
||||||
* you may not use this file except in compliance with the License.
|
* you may not use this file except in compliance with the License.
|
||||||
|
|||||||
@@ -1,5 +1,5 @@
|
|||||||
/*
|
/*
|
||||||
* Copyright 2021-2022 the original author or authors.
|
* Copyright 2021-2023 the original author or authors.
|
||||||
*
|
*
|
||||||
* Licensed under the Apache License, Version 2.0 (the "License");
|
* Licensed under the Apache License, Version 2.0 (the "License");
|
||||||
* you may not use this file except in compliance with the License.
|
* you may not use this file except in compliance with the License.
|
||||||
|
|||||||
@@ -1,5 +1,5 @@
|
|||||||
/*
|
/*
|
||||||
* Copyright 2022 the original author or authors.
|
* Copyright 2022-2023 the original author or authors.
|
||||||
*
|
*
|
||||||
* Licensed under the Apache License, Version 2.0 (the "License");
|
* Licensed under the Apache License, Version 2.0 (the "License");
|
||||||
* you may not use this file except in compliance with the License.
|
* you may not use this file except in compliance with the License.
|
||||||
|
|||||||
@@ -1,5 +1,5 @@
|
|||||||
/*
|
/*
|
||||||
* Copyright 2018-2022 the original author or authors.
|
* Copyright 2018-2023 the original author or authors.
|
||||||
*
|
*
|
||||||
* Licensed under the Apache License, Version 2.0 (the "License");
|
* Licensed under the Apache License, Version 2.0 (the "License");
|
||||||
* you may not use this file except in compliance with the License.
|
* you may not use this file except in compliance with the License.
|
||||||
|
|||||||
@@ -1,5 +1,5 @@
|
|||||||
/*
|
/*
|
||||||
* Copyright 2018-2022 the original author or authors.
|
* Copyright 2018-2023 the original author or authors.
|
||||||
*
|
*
|
||||||
* Licensed under the Apache License, Version 2.0 (the "License");
|
* Licensed under the Apache License, Version 2.0 (the "License");
|
||||||
* you may not use this file except in compliance with the License.
|
* you may not use this file except in compliance with the License.
|
||||||
|
|||||||
@@ -1,5 +1,5 @@
|
|||||||
/*
|
/*
|
||||||
* Copyright 2018-2022 the original author or authors.
|
* Copyright 2018-2023 the original author or authors.
|
||||||
*
|
*
|
||||||
* Licensed under the Apache License, Version 2.0 (the "License");
|
* Licensed under the Apache License, Version 2.0 (the "License");
|
||||||
* you may not use this file except in compliance with the License.
|
* you may not use this file except in compliance with the License.
|
||||||
|
|||||||
@@ -1,5 +1,5 @@
|
|||||||
/*
|
/*
|
||||||
* Copyright 2018-2022 the original author or authors.
|
* Copyright 2018-2023 the original author or authors.
|
||||||
*
|
*
|
||||||
* Licensed under the Apache License, Version 2.0 (the "License");
|
* Licensed under the Apache License, Version 2.0 (the "License");
|
||||||
* you may not use this file except in compliance with the License.
|
* you may not use this file except in compliance with the License.
|
||||||
@@ -353,7 +353,7 @@ public class MongoTransactionManager extends AbstractPlatformTransactionManager
|
|||||||
debugString += String.format("causallyConsistent = %s, ", session.isCausallyConsistent());
|
debugString += String.format("causallyConsistent = %s, ", session.isCausallyConsistent());
|
||||||
debugString += String.format("txActive = %s, ", session.hasActiveTransaction());
|
debugString += String.format("txActive = %s, ", session.hasActiveTransaction());
|
||||||
debugString += String.format("txNumber = %d, ", session.getServerSession().getTransactionNumber());
|
debugString += String.format("txNumber = %d, ", session.getServerSession().getTransactionNumber());
|
||||||
debugString += String.format("closed = %d, ", session.getServerSession().isClosed());
|
debugString += String.format("closed = %b, ", session.getServerSession().isClosed());
|
||||||
debugString += String.format("clusterTime = %s", session.getClusterTime());
|
debugString += String.format("clusterTime = %s", session.getClusterTime());
|
||||||
} else {
|
} else {
|
||||||
debugString += "id = n/a";
|
debugString += "id = n/a";
|
||||||
|
|||||||
@@ -1,5 +1,5 @@
|
|||||||
/*
|
/*
|
||||||
* Copyright 2016-2022 the original author or authors.
|
* Copyright 2016-2023 the original author or authors.
|
||||||
*
|
*
|
||||||
* Licensed under the Apache License, Version 2.0 (the "License");
|
* Licensed under the Apache License, Version 2.0 (the "License");
|
||||||
* you may not use this file except in compliance with the License.
|
* you may not use this file except in compliance with the License.
|
||||||
|
|||||||
@@ -1,5 +1,5 @@
|
|||||||
/*
|
/*
|
||||||
* Copyright 2019-2022 the original author or authors.
|
* Copyright 2019-2023 the original author or authors.
|
||||||
*
|
*
|
||||||
* Licensed under the Apache License, Version 2.0 (the "License");
|
* Licensed under the Apache License, Version 2.0 (the "License");
|
||||||
* you may not use this file except in compliance with the License.
|
* you may not use this file except in compliance with the License.
|
||||||
|
|||||||
@@ -1,5 +1,5 @@
|
|||||||
/*
|
/*
|
||||||
* Copyright 2019-2022 the original author or authors.
|
* Copyright 2019-2023 the original author or authors.
|
||||||
*
|
*
|
||||||
* Licensed under the Apache License, Version 2.0 (the "License");
|
* Licensed under the Apache License, Version 2.0 (the "License");
|
||||||
* you may not use this file except in compliance with the License.
|
* you may not use this file except in compliance with the License.
|
||||||
|
|||||||
@@ -1,5 +1,5 @@
|
|||||||
/*
|
/*
|
||||||
* Copyright 2019-2022 the original author or authors.
|
* Copyright 2019-2023 the original author or authors.
|
||||||
*
|
*
|
||||||
* Licensed under the Apache License, Version 2.0 (the "License");
|
* Licensed under the Apache License, Version 2.0 (the "License");
|
||||||
* you may not use this file except in compliance with the License.
|
* you may not use this file except in compliance with the License.
|
||||||
@@ -361,7 +361,7 @@ public class ReactiveMongoTransactionManager extends AbstractReactiveTransaction
|
|||||||
debugString += String.format("causallyConsistent = %s, ", session.isCausallyConsistent());
|
debugString += String.format("causallyConsistent = %s, ", session.isCausallyConsistent());
|
||||||
debugString += String.format("txActive = %s, ", session.hasActiveTransaction());
|
debugString += String.format("txActive = %s, ", session.hasActiveTransaction());
|
||||||
debugString += String.format("txNumber = %d, ", session.getServerSession().getTransactionNumber());
|
debugString += String.format("txNumber = %d, ", session.getServerSession().getTransactionNumber());
|
||||||
debugString += String.format("closed = %d, ", session.getServerSession().isClosed());
|
debugString += String.format("closed = %b, ", session.getServerSession().isClosed());
|
||||||
debugString += String.format("clusterTime = %s", session.getClusterTime());
|
debugString += String.format("clusterTime = %s", session.getClusterTime());
|
||||||
} else {
|
} else {
|
||||||
debugString += "id = n/a";
|
debugString += "id = n/a";
|
||||||
|
|||||||
@@ -1,5 +1,5 @@
|
|||||||
/*
|
/*
|
||||||
* Copyright 2018-2022 the original author or authors.
|
* Copyright 2018-2023 the original author or authors.
|
||||||
*
|
*
|
||||||
* Licensed under the Apache License, Version 2.0 (the "License");
|
* Licensed under the Apache License, Version 2.0 (the "License");
|
||||||
* you may not use this file except in compliance with the License.
|
* you may not use this file except in compliance with the License.
|
||||||
|
|||||||
@@ -1,5 +1,5 @@
|
|||||||
/*
|
/*
|
||||||
* Copyright 2018-2022 the original author or authors.
|
* Copyright 2018-2023 the original author or authors.
|
||||||
*
|
*
|
||||||
* Licensed under the Apache License, Version 2.0 (the "License");
|
* Licensed under the Apache License, Version 2.0 (the "License");
|
||||||
* you may not use this file except in compliance with the License.
|
* you may not use this file except in compliance with the License.
|
||||||
|
|||||||
@@ -1,5 +1,5 @@
|
|||||||
/*
|
/*
|
||||||
* Copyright 2020-2022 the original author or authors.
|
* Copyright 2020-2023 the original author or authors.
|
||||||
*
|
*
|
||||||
* Licensed under the Apache License, Version 2.0 (the "License");
|
* Licensed under the Apache License, Version 2.0 (the "License");
|
||||||
* you may not use this file except in compliance with the License.
|
* you may not use this file except in compliance with the License.
|
||||||
|
|||||||
@@ -1,5 +1,5 @@
|
|||||||
/*
|
/*
|
||||||
* Copyright 2010-2022 the original author or authors.
|
* Copyright 2010-2023 the original author or authors.
|
||||||
*
|
*
|
||||||
* Licensed under the Apache License, Version 2.0 (the "License");
|
* Licensed under the Apache License, Version 2.0 (the "License");
|
||||||
* you may not use this file except in compliance with the License.
|
* you may not use this file except in compliance with the License.
|
||||||
|
|||||||
@@ -1,5 +1,5 @@
|
|||||||
/*
|
/*
|
||||||
* Copyright 2022 the original author or authors.
|
* Copyright 2022-2023 the original author or authors.
|
||||||
*
|
*
|
||||||
* Licensed under the Apache License, Version 2.0 (the "License");
|
* Licensed under the Apache License, Version 2.0 (the "License");
|
||||||
* you may not use this file except in compliance with the License.
|
* you may not use this file except in compliance with the License.
|
||||||
@@ -23,24 +23,27 @@ import java.util.List;
|
|||||||
import java.util.Set;
|
import java.util.Set;
|
||||||
|
|
||||||
import org.springframework.aot.generate.GenerationContext;
|
import org.springframework.aot.generate.GenerationContext;
|
||||||
|
import org.springframework.aot.hint.MemberCategory;
|
||||||
import org.springframework.aot.hint.TypeReference;
|
import org.springframework.aot.hint.TypeReference;
|
||||||
import org.springframework.core.ResolvableType;
|
import org.springframework.core.ResolvableType;
|
||||||
import org.springframework.core.annotation.AnnotatedElementUtils;
|
import org.springframework.core.annotation.AnnotatedElementUtils;
|
||||||
import org.springframework.core.annotation.MergedAnnotations;
|
import org.springframework.core.annotation.MergedAnnotations;
|
||||||
import org.springframework.data.annotation.Reference;
|
import org.springframework.data.annotation.Reference;
|
||||||
import org.springframework.data.aot.TypeUtils;
|
import org.springframework.data.mongodb.core.convert.LazyLoadingProxyFactory;
|
||||||
|
import org.springframework.data.mongodb.core.convert.LazyLoadingProxyFactory.LazyLoadingInterceptor;
|
||||||
import org.springframework.data.mongodb.core.mapping.DBRef;
|
import org.springframework.data.mongodb.core.mapping.DBRef;
|
||||||
import org.springframework.data.mongodb.core.mapping.DocumentReference;
|
import org.springframework.data.mongodb.core.mapping.DocumentReference;
|
||||||
|
import org.springframework.data.util.TypeUtils;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* @author Christoph Strobl
|
* @author Christoph Strobl
|
||||||
* @since 4.0
|
* @since 4.0
|
||||||
*/
|
*/
|
||||||
class LazyLoadingProxyAotProcessor {
|
public class LazyLoadingProxyAotProcessor {
|
||||||
|
|
||||||
private boolean generalLazyLoadingProxyContributed = false;
|
private boolean generalLazyLoadingProxyContributed = false;
|
||||||
|
|
||||||
void registerLazyLoadingProxyIfNeeded(Class<?> type, GenerationContext generationContext) {
|
public void registerLazyLoadingProxyIfNeeded(Class<?> type, GenerationContext generationContext) {
|
||||||
|
|
||||||
Set<Field> refFields = getFieldsWithAnnotationPresent(type, Reference.class);
|
Set<Field> refFields = getFieldsWithAnnotationPresent(type, Reference.class);
|
||||||
if (refFields.isEmpty()) {
|
if (refFields.isEmpty()) {
|
||||||
@@ -73,9 +76,12 @@ class LazyLoadingProxyAotProcessor {
|
|||||||
generationContext.getRuntimeHints().proxies().registerJdkProxy(interfaces.toArray(Class[]::new));
|
generationContext.getRuntimeHints().proxies().registerJdkProxy(interfaces.toArray(Class[]::new));
|
||||||
} else {
|
} else {
|
||||||
|
|
||||||
generationContext.getRuntimeHints().proxies().registerClassProxy(field.getType(), builder -> {
|
Class<?> proxyClass = LazyLoadingProxyFactory.resolveProxyType(field.getType(),
|
||||||
builder.proxiedInterfaces(org.springframework.data.mongodb.core.convert.LazyLoadingProxy.class);
|
() -> LazyLoadingInterceptor.none());
|
||||||
});
|
|
||||||
|
// see: spring-projects/spring-framework/issues/29309
|
||||||
|
generationContext.getRuntimeHints().reflection().registerType(proxyClass,
|
||||||
|
MemberCategory.INVOKE_DECLARED_CONSTRUCTORS, MemberCategory.INVOKE_DECLARED_METHODS, MemberCategory.DECLARED_FIELDS);
|
||||||
}
|
}
|
||||||
});
|
});
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -1,5 +1,5 @@
|
|||||||
/*
|
/*
|
||||||
* Copyright 2022 the original author or authors.
|
* Copyright 2022-2023 the original author or authors.
|
||||||
*
|
*
|
||||||
* Licensed under the Apache License, Version 2.0 (the "License");
|
* Licensed under the Apache License, Version 2.0 (the "License");
|
||||||
* you may not use this file except in compliance with the License.
|
* you may not use this file except in compliance with the License.
|
||||||
@@ -17,15 +17,29 @@ package org.springframework.data.mongodb.aot;
|
|||||||
|
|
||||||
import java.util.function.Predicate;
|
import java.util.function.Predicate;
|
||||||
|
|
||||||
import org.springframework.data.aot.TypeUtils;
|
|
||||||
import org.springframework.data.mongodb.core.mapping.MongoSimpleTypes;
|
import org.springframework.data.mongodb.core.mapping.MongoSimpleTypes;
|
||||||
|
import org.springframework.data.util.ReactiveWrappers;
|
||||||
|
import org.springframework.data.util.ReactiveWrappers.ReactiveLibrary;
|
||||||
|
import org.springframework.data.util.TypeUtils;
|
||||||
|
import org.springframework.lang.Nullable;
|
||||||
|
import org.springframework.util.ClassUtils;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* @author Christoph Strobl
|
* @author Christoph Strobl
|
||||||
* @since 4.0
|
* @since 4.0
|
||||||
*/
|
*/
|
||||||
class MongoAotPredicates {
|
public class MongoAotPredicates {
|
||||||
|
|
||||||
static final Predicate<Class<?>> IS_SIMPLE_TYPE = (type) -> MongoSimpleTypes.HOLDER.isSimpleType(type) || TypeUtils.type(type).isPartOf("org.bson");
|
public static final Predicate<Class<?>> IS_SIMPLE_TYPE = (type) -> MongoSimpleTypes.HOLDER.isSimpleType(type) || TypeUtils.type(type).isPartOf("org.bson");
|
||||||
|
public static final Predicate<ReactiveLibrary> IS_REACTIVE_LIBARARY_AVAILABLE = (lib) -> ReactiveWrappers.isAvailable(lib);
|
||||||
|
public static final Predicate<ClassLoader> IS_SYNC_CLIENT_PRESENT = (classLoader) -> ClassUtils.isPresent("com.mongodb.client.MongoClient", classLoader);
|
||||||
|
|
||||||
|
public static boolean isReactorPresent() {
|
||||||
|
return IS_REACTIVE_LIBARARY_AVAILABLE.test(ReactiveWrappers.ReactiveLibrary.PROJECT_REACTOR);
|
||||||
|
}
|
||||||
|
|
||||||
|
public static boolean isSyncClientPresent(@Nullable ClassLoader classLoader) {
|
||||||
|
return IS_SYNC_CLIENT_PRESENT.test(classLoader);
|
||||||
|
}
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -1,5 +1,5 @@
|
|||||||
/*
|
/*
|
||||||
* Copyright 2022 the original author or authors.
|
* Copyright 2022-2023 the original author or authors.
|
||||||
*
|
*
|
||||||
* Licensed under the Apache License, Version 2.0 (the "License");
|
* Licensed under the Apache License, Version 2.0 (the "License");
|
||||||
* you may not use this file except in compliance with the License.
|
* you may not use this file except in compliance with the License.
|
||||||
|
|||||||
@@ -1,5 +1,5 @@
|
|||||||
/*
|
/*
|
||||||
* Copyright 2022 the original author or authors.
|
* Copyright 2022-2023 the original author or authors.
|
||||||
*
|
*
|
||||||
* Licensed under the Apache License, Version 2.0 (the "License");
|
* Licensed under the Apache License, Version 2.0 (the "License");
|
||||||
* you may not use this file except in compliance with the License.
|
* you may not use this file except in compliance with the License.
|
||||||
@@ -15,6 +15,8 @@
|
|||||||
*/
|
*/
|
||||||
package org.springframework.data.mongodb.aot;
|
package org.springframework.data.mongodb.aot;
|
||||||
|
|
||||||
|
import static org.springframework.data.mongodb.aot.MongoAotPredicates.*;
|
||||||
|
|
||||||
import java.util.Arrays;
|
import java.util.Arrays;
|
||||||
|
|
||||||
import org.springframework.aot.hint.MemberCategory;
|
import org.springframework.aot.hint.MemberCategory;
|
||||||
@@ -29,10 +31,8 @@ import org.springframework.data.mongodb.core.mapping.event.ReactiveAfterConvertC
|
|||||||
import org.springframework.data.mongodb.core.mapping.event.ReactiveAfterSaveCallback;
|
import org.springframework.data.mongodb.core.mapping.event.ReactiveAfterSaveCallback;
|
||||||
import org.springframework.data.mongodb.core.mapping.event.ReactiveBeforeConvertCallback;
|
import org.springframework.data.mongodb.core.mapping.event.ReactiveBeforeConvertCallback;
|
||||||
import org.springframework.data.mongodb.core.mapping.event.ReactiveBeforeSaveCallback;
|
import org.springframework.data.mongodb.core.mapping.event.ReactiveBeforeSaveCallback;
|
||||||
import org.springframework.data.mongodb.repository.support.SimpleMongoRepository;
|
|
||||||
import org.springframework.data.mongodb.repository.support.SimpleReactiveMongoRepository;
|
|
||||||
import org.springframework.data.repository.util.ReactiveWrappers;
|
|
||||||
import org.springframework.lang.Nullable;
|
import org.springframework.lang.Nullable;
|
||||||
|
import org.springframework.util.ClassUtils;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* {@link RuntimeHintsRegistrar} for repository types and entity callbacks.
|
* {@link RuntimeHintsRegistrar} for repository types and entity callbacks.
|
||||||
@@ -43,27 +43,41 @@ import org.springframework.lang.Nullable;
|
|||||||
*/
|
*/
|
||||||
class MongoRuntimeHints implements RuntimeHintsRegistrar {
|
class MongoRuntimeHints implements RuntimeHintsRegistrar {
|
||||||
|
|
||||||
private static final boolean PROJECT_REACTOR_PRESENT = ReactiveWrappers
|
|
||||||
.isAvailable(ReactiveWrappers.ReactiveLibrary.PROJECT_REACTOR);
|
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public void registerHints(RuntimeHints hints, @Nullable ClassLoader classLoader) {
|
public void registerHints(RuntimeHints hints, @Nullable ClassLoader classLoader) {
|
||||||
|
|
||||||
hints.reflection().registerTypes(
|
hints.reflection().registerTypes(
|
||||||
Arrays.asList(TypeReference.of(SimpleMongoRepository.class), TypeReference.of(BeforeConvertCallback.class),
|
Arrays.asList(TypeReference.of(BeforeConvertCallback.class), TypeReference.of(BeforeSaveCallback.class),
|
||||||
TypeReference.of(BeforeSaveCallback.class), TypeReference.of(AfterConvertCallback.class),
|
TypeReference.of(AfterConvertCallback.class), TypeReference.of(AfterSaveCallback.class)),
|
||||||
TypeReference.of(AfterSaveCallback.class)),
|
|
||||||
builder -> builder.withMembers(MemberCategory.INVOKE_DECLARED_CONSTRUCTORS,
|
builder -> builder.withMembers(MemberCategory.INVOKE_DECLARED_CONSTRUCTORS,
|
||||||
MemberCategory.INVOKE_PUBLIC_METHODS));
|
MemberCategory.INVOKE_PUBLIC_METHODS));
|
||||||
|
|
||||||
if (PROJECT_REACTOR_PRESENT) {
|
registerTransactionProxyHints(hints, classLoader);
|
||||||
|
|
||||||
|
if (isReactorPresent()) {
|
||||||
|
|
||||||
hints.reflection()
|
hints.reflection()
|
||||||
.registerTypes(Arrays.asList(TypeReference.of(SimpleReactiveMongoRepository.class),
|
.registerTypes(Arrays.asList(TypeReference.of(ReactiveBeforeConvertCallback.class),
|
||||||
TypeReference.of(ReactiveBeforeConvertCallback.class), TypeReference.of(ReactiveBeforeSaveCallback.class),
|
TypeReference.of(ReactiveBeforeSaveCallback.class), TypeReference.of(ReactiveAfterConvertCallback.class),
|
||||||
TypeReference.of(ReactiveAfterConvertCallback.class), TypeReference.of(ReactiveAfterSaveCallback.class)),
|
TypeReference.of(ReactiveAfterSaveCallback.class)),
|
||||||
builder -> builder.withMembers(MemberCategory.INVOKE_DECLARED_CONSTRUCTORS,
|
builder -> builder.withMembers(MemberCategory.INVOKE_DECLARED_CONSTRUCTORS,
|
||||||
MemberCategory.INVOKE_PUBLIC_METHODS));
|
MemberCategory.INVOKE_PUBLIC_METHODS));
|
||||||
}
|
}
|
||||||
|
|
||||||
|
}
|
||||||
|
|
||||||
|
private static void registerTransactionProxyHints(RuntimeHints hints, @Nullable ClassLoader classLoader) {
|
||||||
|
|
||||||
|
if (MongoAotPredicates.isSyncClientPresent(classLoader)
|
||||||
|
&& ClassUtils.isPresent("org.springframework.aop.SpringProxy", classLoader)) {
|
||||||
|
|
||||||
|
hints.proxies().registerJdkProxy(TypeReference.of("com.mongodb.client.MongoDatabase"),
|
||||||
|
TypeReference.of("org.springframework.aop.SpringProxy"),
|
||||||
|
TypeReference.of("org.springframework.core.DecoratingProxy"));
|
||||||
|
hints.proxies().registerJdkProxy(TypeReference.of("com.mongodb.client.MongoCollection"),
|
||||||
|
TypeReference.of("org.springframework.aop.SpringProxy"),
|
||||||
|
TypeReference.of("org.springframework.core.DecoratingProxy"));
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
}
|
||||||
|
|||||||
@@ -1,5 +1,5 @@
|
|||||||
/*
|
/*
|
||||||
* Copyright 2018-2022 the original author or authors.
|
* Copyright 2018-2023 the original author or authors.
|
||||||
*
|
*
|
||||||
* Licensed under the Apache License, Version 2.0 (the "License");
|
* Licensed under the Apache License, Version 2.0 (the "License");
|
||||||
* you may not use this file except in compliance with the License.
|
* you may not use this file except in compliance with the License.
|
||||||
|
|||||||
@@ -1,5 +1,5 @@
|
|||||||
/*
|
/*
|
||||||
* Copyright 2016-2022 the original author or authors.
|
* Copyright 2016-2023 the original author or authors.
|
||||||
*
|
*
|
||||||
* Licensed under the Apache License, Version 2.0 (the "License");
|
* Licensed under the Apache License, Version 2.0 (the "License");
|
||||||
* you may not use this file except in compliance with the License.
|
* you may not use this file except in compliance with the License.
|
||||||
|
|||||||
@@ -1,5 +1,5 @@
|
|||||||
/*
|
/*
|
||||||
* Copyright 2011-2022 the original author or authors.
|
* Copyright 2011-2023 the original author or authors.
|
||||||
*
|
*
|
||||||
* Licensed under the Apache License, Version 2.0 (the "License");
|
* Licensed under the Apache License, Version 2.0 (the "License");
|
||||||
* you may not use this file except in compliance with the License.
|
* you may not use this file except in compliance with the License.
|
||||||
|
|||||||
@@ -1,5 +1,5 @@
|
|||||||
/*
|
/*
|
||||||
* Copyright 2019-2022 the original author or authors.
|
* Copyright 2019-2023 the original author or authors.
|
||||||
*
|
*
|
||||||
* Licensed under the Apache License, Version 2.0 (the "License");
|
* Licensed under the Apache License, Version 2.0 (the "License");
|
||||||
* you may not use this file except in compliance with the License.
|
* you may not use this file except in compliance with the License.
|
||||||
|
|||||||
@@ -1,5 +1,5 @@
|
|||||||
/*
|
/*
|
||||||
* Copyright 2013-2022 the original author or authors.
|
* Copyright 2013-2023 the original author or authors.
|
||||||
*
|
*
|
||||||
* Licensed under the Apache License, Version 2.0 (the "License");
|
* Licensed under the Apache License, Version 2.0 (the "License");
|
||||||
* you may not use this file except in compliance with the License.
|
* you may not use this file except in compliance with the License.
|
||||||
|
|||||||
@@ -1,5 +1,5 @@
|
|||||||
/*
|
/*
|
||||||
* Copyright 2020-2022 the original author or authors.
|
* Copyright 2020-2023 the original author or authors.
|
||||||
*
|
*
|
||||||
* Licensed under the Apache License, Version 2.0 (the "License");
|
* Licensed under the Apache License, Version 2.0 (the "License");
|
||||||
* you may not use this file except in compliance with the License.
|
* you may not use this file except in compliance with the License.
|
||||||
|
|||||||
@@ -1,5 +1,5 @@
|
|||||||
/*
|
/*
|
||||||
* Copyright 2015-2022 the original author or authors.
|
* Copyright 2015-2023 the original author or authors.
|
||||||
*
|
*
|
||||||
* Licensed under the Apache License, Version 2.0 (the "License");
|
* Licensed under the Apache License, Version 2.0 (the "License");
|
||||||
* you may not use this file except in compliance with the License.
|
* you may not use this file except in compliance with the License.
|
||||||
|
|||||||
@@ -1,5 +1,5 @@
|
|||||||
/*
|
/*
|
||||||
* Copyright 2013-2022 the original author or authors.
|
* Copyright 2013-2023 the original author or authors.
|
||||||
*
|
*
|
||||||
* Licensed under the Apache License, Version 2.0 (the "License");
|
* Licensed under the Apache License, Version 2.0 (the "License");
|
||||||
* you may not use this file except in compliance with the License.
|
* you may not use this file except in compliance with the License.
|
||||||
|
|||||||
@@ -1,5 +1,5 @@
|
|||||||
/*
|
/*
|
||||||
* Copyright 2011-2022 the original author or authors.
|
* Copyright 2011-2023 the original author or authors.
|
||||||
*
|
*
|
||||||
* Licensed under the Apache License, Version 2.0 (the "License");
|
* Licensed under the Apache License, Version 2.0 (the "License");
|
||||||
* you may not use this file except in compliance with the License.
|
* you may not use this file except in compliance with the License.
|
||||||
|
|||||||
@@ -1,5 +1,5 @@
|
|||||||
/*
|
/*
|
||||||
* Copyright 2012-2022 the original author or authors.
|
* Copyright 2012-2023 the original author or authors.
|
||||||
*
|
*
|
||||||
* Licensed under the Apache License, Version 2.0 (the "License");
|
* Licensed under the Apache License, Version 2.0 (the "License");
|
||||||
* you may not use this file except in compliance with the License.
|
* you may not use this file except in compliance with the License.
|
||||||
|
|||||||
@@ -1,5 +1,5 @@
|
|||||||
/*
|
/*
|
||||||
* Copyright 2013-2022 the original author or authors.
|
* Copyright 2013-2023 the original author or authors.
|
||||||
*
|
*
|
||||||
* Licensed under the Apache License, Version 2.0 (the "License");
|
* Licensed under the Apache License, Version 2.0 (the "License");
|
||||||
* you may not use this file except in compliance with the License.
|
* you may not use this file except in compliance with the License.
|
||||||
|
|||||||
@@ -1,5 +1,5 @@
|
|||||||
/*
|
/*
|
||||||
* Copyright 2015-2022 the original author or authors.
|
* Copyright 2015-2023 the original author or authors.
|
||||||
*
|
*
|
||||||
* Licensed under the Apache License, Version 2.0 (the "License");
|
* Licensed under the Apache License, Version 2.0 (the "License");
|
||||||
* you may not use this file except in compliance with the License.
|
* you may not use this file except in compliance with the License.
|
||||||
|
|||||||
@@ -1,5 +1,5 @@
|
|||||||
/*
|
/*
|
||||||
* Copyright 2016-2022 the original author or authors.
|
* Copyright 2016-2023 the original author or authors.
|
||||||
*
|
*
|
||||||
* Licensed under the Apache License, Version 2.0 (the "License");
|
* Licensed under the Apache License, Version 2.0 (the "License");
|
||||||
* you may not use this file except in compliance with the License.
|
* you may not use this file except in compliance with the License.
|
||||||
@@ -27,7 +27,6 @@ import org.springframework.context.annotation.ClassPathScanningCandidateComponen
|
|||||||
import org.springframework.core.convert.converter.Converter;
|
import org.springframework.core.convert.converter.Converter;
|
||||||
import org.springframework.core.type.filter.AnnotationTypeFilter;
|
import org.springframework.core.type.filter.AnnotationTypeFilter;
|
||||||
import org.springframework.data.convert.CustomConversions;
|
import org.springframework.data.convert.CustomConversions;
|
||||||
import org.springframework.data.domain.ManagedTypes;
|
|
||||||
import org.springframework.data.mapping.model.CamelCaseAbbreviatingFieldNamingStrategy;
|
import org.springframework.data.mapping.model.CamelCaseAbbreviatingFieldNamingStrategy;
|
||||||
import org.springframework.data.mapping.model.FieldNamingStrategy;
|
import org.springframework.data.mapping.model.FieldNamingStrategy;
|
||||||
import org.springframework.data.mapping.model.PropertyNameFieldNamingStrategy;
|
import org.springframework.data.mapping.model.PropertyNameFieldNamingStrategy;
|
||||||
|
|||||||
@@ -1,5 +1,5 @@
|
|||||||
/*
|
/*
|
||||||
* Copyright 2015-2022 the original author or authors.
|
* Copyright 2015-2023 the original author or authors.
|
||||||
*
|
*
|
||||||
* Licensed under the Apache License, Version 2.0 (the "License");
|
* Licensed under the Apache License, Version 2.0 (the "License");
|
||||||
* you may not use this file except in compliance with the License.
|
* you may not use this file except in compliance with the License.
|
||||||
|
|||||||
@@ -1,5 +1,5 @@
|
|||||||
/*
|
/*
|
||||||
* Copyright 2011-2022 the original author or authors.
|
* Copyright 2011-2023 the original author or authors.
|
||||||
*
|
*
|
||||||
* Licensed under the Apache License, Version 2.0 (the "License");
|
* Licensed under the Apache License, Version 2.0 (the "License");
|
||||||
* you may not use this file except in compliance with the License.
|
* you may not use this file except in compliance with the License.
|
||||||
|
|||||||
@@ -1,5 +1,5 @@
|
|||||||
/*
|
/*
|
||||||
* Copyright 2011-2022 the original author or authors.
|
* Copyright 2011-2023 the original author or authors.
|
||||||
*
|
*
|
||||||
* Licensed under the Apache License, Version 2.0 (the "License");
|
* Licensed under the Apache License, Version 2.0 (the "License");
|
||||||
* you may not use this file except in compliance with the License.
|
* you may not use this file except in compliance with the License.
|
||||||
|
|||||||
@@ -1,5 +1,5 @@
|
|||||||
/*
|
/*
|
||||||
* Copyright 2011-2022 the original author or authors.
|
* Copyright 2011-2023 the original author or authors.
|
||||||
*
|
*
|
||||||
* Licensed under the Apache License, Version 2.0 (the "License");
|
* Licensed under the Apache License, Version 2.0 (the "License");
|
||||||
* you may not use this file except in compliance with the License.
|
* you may not use this file except in compliance with the License.
|
||||||
|
|||||||
@@ -1,5 +1,5 @@
|
|||||||
/*
|
/*
|
||||||
* Copyright 2011-2022 the original author or authors.
|
* Copyright 2011-2023 the original author or authors.
|
||||||
*
|
*
|
||||||
* Licensed under the Apache License, Version 2.0 (the "License");
|
* Licensed under the Apache License, Version 2.0 (the "License");
|
||||||
* you may not use this file except in compliance with the License.
|
* you may not use this file except in compliance with the License.
|
||||||
|
|||||||
@@ -1,5 +1,5 @@
|
|||||||
/*
|
/*
|
||||||
* Copyright 2011-2022 the original author or authors.
|
* Copyright 2011-2023 the original author or authors.
|
||||||
*
|
*
|
||||||
* Licensed under the Apache License, Version 2.0 (the "License");
|
* Licensed under the Apache License, Version 2.0 (the "License");
|
||||||
* you may not use this file except in compliance with the License.
|
* you may not use this file except in compliance with the License.
|
||||||
|
|||||||
@@ -1,5 +1,5 @@
|
|||||||
/*
|
/*
|
||||||
* Copyright 2020-2022 the original author or authors.
|
* Copyright 2020-2023 the original author or authors.
|
||||||
*
|
*
|
||||||
* Licensed under the Apache License, Version 2.0 (the "License");
|
* Licensed under the Apache License, Version 2.0 (the "License");
|
||||||
* you may not use this file except in compliance with the License.
|
* you may not use this file except in compliance with the License.
|
||||||
|
|||||||
@@ -1,5 +1,5 @@
|
|||||||
/*
|
/*
|
||||||
* Copyright 2020-2022 the original author or authors.
|
* Copyright 2020-2023 the original author or authors.
|
||||||
*
|
*
|
||||||
* Licensed under the Apache License, Version 2.0 (the "License");
|
* Licensed under the Apache License, Version 2.0 (the "License");
|
||||||
* you may not use this file except in compliance with the License.
|
* you may not use this file except in compliance with the License.
|
||||||
|
|||||||
@@ -1,5 +1,5 @@
|
|||||||
/*
|
/*
|
||||||
* Copyright 2019-2022 the original author or authors.
|
* Copyright 2019-2023 the original author or authors.
|
||||||
*
|
*
|
||||||
* Licensed under the Apache License, Version 2.0 (the "License");
|
* Licensed under the Apache License, Version 2.0 (the "License");
|
||||||
* you may not use this file except in compliance with the License.
|
* you may not use this file except in compliance with the License.
|
||||||
|
|||||||
@@ -1,5 +1,5 @@
|
|||||||
/*
|
/*
|
||||||
* Copyright 2015-2022 the original author or authors.
|
* Copyright 2015-2023 the original author or authors.
|
||||||
*
|
*
|
||||||
* Licensed under the Apache License, Version 2.0 (the "License");
|
* Licensed under the Apache License, Version 2.0 (the "License");
|
||||||
* you may not use this file except in compliance with the License.
|
* you may not use this file except in compliance with the License.
|
||||||
|
|||||||
@@ -1,5 +1,5 @@
|
|||||||
/*
|
/*
|
||||||
* Copyright 2011-2022 the original author or authors.
|
* Copyright 2011-2023 the original author or authors.
|
||||||
*
|
*
|
||||||
* Licensed under the Apache License, Version 2.0 (the "License");
|
* Licensed under the Apache License, Version 2.0 (the "License");
|
||||||
* you may not use this file except in compliance with the License.
|
* you may not use this file except in compliance with the License.
|
||||||
|
|||||||
@@ -1,5 +1,5 @@
|
|||||||
/*
|
/*
|
||||||
* Copyright 2012-2022 the original author or authors.
|
* Copyright 2012-2023 the original author or authors.
|
||||||
*
|
*
|
||||||
* Licensed under the Apache License, Version 2.0 (the "License");
|
* Licensed under the Apache License, Version 2.0 (the "License");
|
||||||
* you may not use this file except in compliance with the License.
|
* you may not use this file except in compliance with the License.
|
||||||
|
|||||||
@@ -1,5 +1,5 @@
|
|||||||
/*
|
/*
|
||||||
* Copyright 2020-2022 the original author or authors.
|
* Copyright 2020-2023 the original author or authors.
|
||||||
*
|
*
|
||||||
* Licensed under the Apache License, Version 2.0 (the "License");
|
* Licensed under the Apache License, Version 2.0 (the "License");
|
||||||
* you may not use this file except in compliance with the License.
|
* you may not use this file except in compliance with the License.
|
||||||
|
|||||||
@@ -1,5 +1,5 @@
|
|||||||
/*
|
/*
|
||||||
* Copyright 2011-2022 the original author or authors.
|
* Copyright 2011-2023 the original author or authors.
|
||||||
*
|
*
|
||||||
* Licensed under the Apache License, Version 2.0 (the "License");
|
* Licensed under the Apache License, Version 2.0 (the "License");
|
||||||
* you may not use this file except in compliance with the License.
|
* you may not use this file except in compliance with the License.
|
||||||
|
|||||||
@@ -1,5 +1,5 @@
|
|||||||
/*
|
/*
|
||||||
* Copyright 2018-2022 the original author or authors.
|
* Copyright 2018-2023 the original author or authors.
|
||||||
*
|
*
|
||||||
* Licensed under the Apache License, Version 2.0 (the "License");
|
* Licensed under the Apache License, Version 2.0 (the "License");
|
||||||
* you may not use this file except in compliance with the License.
|
* you may not use this file except in compliance with the License.
|
||||||
@@ -15,8 +15,6 @@
|
|||||||
*/
|
*/
|
||||||
package org.springframework.data.mongodb.core;
|
package org.springframework.data.mongodb.core;
|
||||||
|
|
||||||
import java.util.Arrays;
|
|
||||||
import java.util.Collections;
|
|
||||||
import java.util.List;
|
import java.util.List;
|
||||||
import java.util.Optional;
|
import java.util.Optional;
|
||||||
import java.util.stream.Collectors;
|
import java.util.stream.Collectors;
|
||||||
@@ -24,23 +22,16 @@ import java.util.stream.Collectors;
|
|||||||
import org.bson.Document;
|
import org.bson.Document;
|
||||||
import org.springframework.data.mapping.context.MappingContext;
|
import org.springframework.data.mapping.context.MappingContext;
|
||||||
import org.springframework.data.mongodb.core.aggregation.Aggregation;
|
import org.springframework.data.mongodb.core.aggregation.Aggregation;
|
||||||
import org.springframework.data.mongodb.core.aggregation.AggregationOperation;
|
|
||||||
import org.springframework.data.mongodb.core.aggregation.AggregationOperationContext;
|
import org.springframework.data.mongodb.core.aggregation.AggregationOperationContext;
|
||||||
import org.springframework.data.mongodb.core.aggregation.AggregationOptions;
|
|
||||||
import org.springframework.data.mongodb.core.aggregation.AggregationOptions.DomainTypeMapping;
|
import org.springframework.data.mongodb.core.aggregation.AggregationOptions.DomainTypeMapping;
|
||||||
import org.springframework.data.mongodb.core.aggregation.CountOperation;
|
|
||||||
import org.springframework.data.mongodb.core.aggregation.RelaxedTypeBasedAggregationOperationContext;
|
import org.springframework.data.mongodb.core.aggregation.RelaxedTypeBasedAggregationOperationContext;
|
||||||
import org.springframework.data.mongodb.core.aggregation.TypeBasedAggregationOperationContext;
|
import org.springframework.data.mongodb.core.aggregation.TypeBasedAggregationOperationContext;
|
||||||
import org.springframework.data.mongodb.core.aggregation.TypedAggregation;
|
import org.springframework.data.mongodb.core.aggregation.TypedAggregation;
|
||||||
import org.springframework.data.mongodb.core.convert.QueryMapper;
|
import org.springframework.data.mongodb.core.convert.QueryMapper;
|
||||||
import org.springframework.data.mongodb.core.mapping.MongoPersistentEntity;
|
import org.springframework.data.mongodb.core.mapping.MongoPersistentEntity;
|
||||||
import org.springframework.data.mongodb.core.mapping.MongoPersistentProperty;
|
import org.springframework.data.mongodb.core.mapping.MongoPersistentProperty;
|
||||||
import org.springframework.data.mongodb.core.query.CriteriaDefinition;
|
|
||||||
import org.springframework.data.mongodb.core.query.Query;
|
|
||||||
import org.springframework.data.util.Lazy;
|
import org.springframework.data.util.Lazy;
|
||||||
import org.springframework.lang.Nullable;
|
import org.springframework.lang.Nullable;
|
||||||
import org.springframework.util.Assert;
|
|
||||||
import org.springframework.util.ObjectUtils;
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Utility methods to map {@link org.springframework.data.mongodb.core.aggregation.Aggregation} pipeline definitions and
|
* Utility methods to map {@link org.springframework.data.mongodb.core.aggregation.Aggregation} pipeline definitions and
|
||||||
@@ -104,14 +95,9 @@ class AggregationUtil {
|
|||||||
* @return
|
* @return
|
||||||
*/
|
*/
|
||||||
List<Document> createPipeline(Aggregation aggregation, AggregationOperationContext context) {
|
List<Document> createPipeline(Aggregation aggregation, AggregationOperationContext context) {
|
||||||
|
|
||||||
if (ObjectUtils.nullSafeEquals(context, Aggregation.DEFAULT_CONTEXT)) {
|
|
||||||
return aggregation.toPipeline(context);
|
return aggregation.toPipeline(context);
|
||||||
}
|
}
|
||||||
|
|
||||||
return mapAggregationPipeline(aggregation.toPipeline(context));
|
|
||||||
}
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Extract the command and map the aggregation pipeline.
|
* Extract the command and map the aggregation pipeline.
|
||||||
*
|
*
|
||||||
@@ -120,16 +106,7 @@ class AggregationUtil {
|
|||||||
* @return
|
* @return
|
||||||
*/
|
*/
|
||||||
Document createCommand(String collection, Aggregation aggregation, AggregationOperationContext context) {
|
Document createCommand(String collection, Aggregation aggregation, AggregationOperationContext context) {
|
||||||
|
return aggregation.toDocument(collection, context);
|
||||||
Document command = aggregation.toDocument(collection, context);
|
|
||||||
|
|
||||||
if (!ObjectUtils.nullSafeEquals(context, Aggregation.DEFAULT_CONTEXT)) {
|
|
||||||
return command;
|
|
||||||
}
|
|
||||||
|
|
||||||
command.put("pipeline", mapAggregationPipeline(command.get("pipeline", List.class)));
|
|
||||||
|
|
||||||
return command;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
private List<Document> mapAggregationPipeline(List<Document> pipeline) {
|
private List<Document> mapAggregationPipeline(List<Document> pipeline) {
|
||||||
|
|||||||
@@ -1,5 +1,5 @@
|
|||||||
/*
|
/*
|
||||||
* Copyright 2015-2022 the original author or authors.
|
* Copyright 2015-2023 the original author or authors.
|
||||||
*
|
*
|
||||||
* Licensed under the Apache License, Version 2.0 (the "License");
|
* Licensed under the Apache License, Version 2.0 (the "License");
|
||||||
* you may not use this file except in compliance with the License.
|
* you may not use this file except in compliance with the License.
|
||||||
@@ -24,10 +24,14 @@ import org.springframework.data.util.Pair;
|
|||||||
import com.mongodb.bulk.BulkWriteResult;
|
import com.mongodb.bulk.BulkWriteResult;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Bulk operations for insert/update/remove actions on a collection. These bulks operation are available since MongoDB
|
* Bulk operations for insert/update/remove actions on a collection. Bulk operations are available since MongoDB 2.6 and
|
||||||
* 2.6 and make use of low level bulk commands on the protocol level. This interface defines a fluent API to add
|
* make use of low level bulk commands on the protocol level. This interface defines a fluent API to add multiple single
|
||||||
* multiple single operations or list of similar operations in sequence which can then eventually be executed by calling
|
* operations or list of similar operations in sequence which can then eventually be executed by calling
|
||||||
* {@link #execute()}.
|
* {@link #execute()}.
|
||||||
|
* <p>
|
||||||
|
* Bulk operations are issued as one batch that pulls together all insert, update, and delete operations. Operations
|
||||||
|
* that require individual operation results such as optimistic locking (using {@code @Version}) are not supported and
|
||||||
|
* the version field remains not populated.
|
||||||
*
|
*
|
||||||
* @author Tobias Trelle
|
* @author Tobias Trelle
|
||||||
* @author Oliver Gierke
|
* @author Oliver Gierke
|
||||||
|
|||||||
@@ -1,5 +1,5 @@
|
|||||||
/*
|
/*
|
||||||
* Copyright 2018-2022 the original author or authors.
|
* Copyright 2018-2023 the original author or authors.
|
||||||
*
|
*
|
||||||
* Licensed under the Apache License, Version 2.0 (the "License");
|
* Licensed under the Apache License, Version 2.0 (the "License");
|
||||||
* you may not use this file except in compliance with the License.
|
* you may not use this file except in compliance with the License.
|
||||||
@@ -36,21 +36,29 @@ import com.mongodb.client.model.changestream.OperationType;
|
|||||||
*
|
*
|
||||||
* @author Christoph Strobl
|
* @author Christoph Strobl
|
||||||
* @author Mark Paluch
|
* @author Mark Paluch
|
||||||
|
* @author Myroslav Kosinskyi
|
||||||
* @since 2.1
|
* @since 2.1
|
||||||
*/
|
*/
|
||||||
public class ChangeStreamEvent<T> {
|
public class ChangeStreamEvent<T> {
|
||||||
|
|
||||||
@SuppressWarnings("rawtypes") //
|
@SuppressWarnings("rawtypes") //
|
||||||
private static final AtomicReferenceFieldUpdater<ChangeStreamEvent, Object> CONVERTED_UPDATER = AtomicReferenceFieldUpdater
|
private static final AtomicReferenceFieldUpdater<ChangeStreamEvent, Object> CONVERTED_FULL_DOCUMENT_UPDATER = AtomicReferenceFieldUpdater
|
||||||
.newUpdater(ChangeStreamEvent.class, Object.class, "converted");
|
.newUpdater(ChangeStreamEvent.class, Object.class, "convertedFullDocument");
|
||||||
|
|
||||||
|
@SuppressWarnings("rawtypes") //
|
||||||
|
private static final AtomicReferenceFieldUpdater<ChangeStreamEvent, Object> CONVERTED_FULL_DOCUMENT_BEFORE_CHANGE_UPDATER = AtomicReferenceFieldUpdater
|
||||||
|
.newUpdater(ChangeStreamEvent.class, Object.class, "convertedFullDocumentBeforeChange");
|
||||||
|
|
||||||
private final @Nullable ChangeStreamDocument<Document> raw;
|
private final @Nullable ChangeStreamDocument<Document> raw;
|
||||||
|
|
||||||
private final Class<T> targetType;
|
private final Class<T> targetType;
|
||||||
private final MongoConverter converter;
|
private final MongoConverter converter;
|
||||||
|
|
||||||
// accessed through CONVERTED_UPDATER.
|
// accessed through CONVERTED_FULL_DOCUMENT_UPDATER.
|
||||||
private volatile @Nullable T converted;
|
private volatile @Nullable T convertedFullDocument;
|
||||||
|
|
||||||
|
// accessed through CONVERTED_FULL_DOCUMENT_BEFORE_CHANGE_UPDATER.
|
||||||
|
private volatile @Nullable T convertedFullDocumentBeforeChange;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* @param raw can be {@literal null}.
|
* @param raw can be {@literal null}.
|
||||||
@@ -147,27 +155,43 @@ public class ChangeStreamEvent<T> {
|
|||||||
@Nullable
|
@Nullable
|
||||||
public T getBody() {
|
public T getBody() {
|
||||||
|
|
||||||
if (raw == null) {
|
if (raw == null || raw.getFullDocument() == null) {
|
||||||
return null;
|
return null;
|
||||||
}
|
}
|
||||||
|
|
||||||
Document fullDocument = raw.getFullDocument();
|
return getConvertedFullDocument(raw.getFullDocument());
|
||||||
|
|
||||||
if (fullDocument == null) {
|
|
||||||
return targetType.cast(fullDocument);
|
|
||||||
}
|
}
|
||||||
|
|
||||||
return getConverted(fullDocument);
|
/**
|
||||||
|
* Get the potentially converted {@link ChangeStreamDocument#getFullDocumentBeforeChange() document} before being changed.
|
||||||
|
*
|
||||||
|
* @return {@literal null} when {@link #getRaw()} or {@link ChangeStreamDocument#getFullDocumentBeforeChange()} is
|
||||||
|
* {@literal null}.
|
||||||
|
* @since 4.0
|
||||||
|
*/
|
||||||
|
@Nullable
|
||||||
|
public T getBodyBeforeChange() {
|
||||||
|
|
||||||
|
if (raw == null || raw.getFullDocumentBeforeChange() == null) {
|
||||||
|
return null;
|
||||||
|
}
|
||||||
|
|
||||||
|
return getConvertedFullDocumentBeforeChange(raw.getFullDocumentBeforeChange());
|
||||||
}
|
}
|
||||||
|
|
||||||
@SuppressWarnings("unchecked")
|
@SuppressWarnings("unchecked")
|
||||||
private T getConverted(Document fullDocument) {
|
private T getConvertedFullDocumentBeforeChange(Document fullDocument) {
|
||||||
return (T) doGetConverted(fullDocument);
|
return (T) doGetConverted(fullDocument, CONVERTED_FULL_DOCUMENT_BEFORE_CHANGE_UPDATER);
|
||||||
}
|
}
|
||||||
|
|
||||||
private Object doGetConverted(Document fullDocument) {
|
@SuppressWarnings("unchecked")
|
||||||
|
private T getConvertedFullDocument(Document fullDocument) {
|
||||||
|
return (T) doGetConverted(fullDocument, CONVERTED_FULL_DOCUMENT_UPDATER);
|
||||||
|
}
|
||||||
|
|
||||||
Object result = CONVERTED_UPDATER.get(this);
|
private Object doGetConverted(Document fullDocument, AtomicReferenceFieldUpdater<ChangeStreamEvent, Object> updater) {
|
||||||
|
|
||||||
|
Object result = updater.get(this);
|
||||||
|
|
||||||
if (result != null) {
|
if (result != null) {
|
||||||
return result;
|
return result;
|
||||||
@@ -176,13 +200,13 @@ public class ChangeStreamEvent<T> {
|
|||||||
if (ClassUtils.isAssignable(Document.class, fullDocument.getClass())) {
|
if (ClassUtils.isAssignable(Document.class, fullDocument.getClass())) {
|
||||||
|
|
||||||
result = converter.read(targetType, fullDocument);
|
result = converter.read(targetType, fullDocument);
|
||||||
return CONVERTED_UPDATER.compareAndSet(this, null, result) ? result : CONVERTED_UPDATER.get(this);
|
return updater.compareAndSet(this, null, result) ? result : updater.get(this);
|
||||||
}
|
}
|
||||||
|
|
||||||
if (converter.getConversionService().canConvert(fullDocument.getClass(), targetType)) {
|
if (converter.getConversionService().canConvert(fullDocument.getClass(), targetType)) {
|
||||||
|
|
||||||
result = converter.getConversionService().convert(fullDocument, targetType);
|
result = converter.getConversionService().convert(fullDocument, targetType);
|
||||||
return CONVERTED_UPDATER.compareAndSet(this, null, result) ? result : CONVERTED_UPDATER.get(this);
|
return updater.compareAndSet(this, null, result) ? result : updater.get(this);
|
||||||
}
|
}
|
||||||
|
|
||||||
throw new IllegalArgumentException(
|
throw new IllegalArgumentException(
|
||||||
@@ -195,7 +219,7 @@ public class ChangeStreamEvent<T> {
|
|||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public boolean equals(Object o) {
|
public boolean equals(@Nullable Object o) {
|
||||||
|
|
||||||
if (this == o)
|
if (this == o)
|
||||||
return true;
|
return true;
|
||||||
|
|||||||
@@ -1,5 +1,5 @@
|
|||||||
/*
|
/*
|
||||||
* Copyright 2018-2022 the original author or authors.
|
* Copyright 2018-2023 the original author or authors.
|
||||||
*
|
*
|
||||||
* Licensed under the Apache License, Version 2.0 (the "License");
|
* Licensed under the Apache License, Version 2.0 (the "License");
|
||||||
* you may not use this file except in compliance with the License.
|
* you may not use this file except in compliance with the License.
|
||||||
@@ -32,6 +32,7 @@ import org.springframework.util.ObjectUtils;
|
|||||||
|
|
||||||
import com.mongodb.client.model.changestream.ChangeStreamDocument;
|
import com.mongodb.client.model.changestream.ChangeStreamDocument;
|
||||||
import com.mongodb.client.model.changestream.FullDocument;
|
import com.mongodb.client.model.changestream.FullDocument;
|
||||||
|
import com.mongodb.client.model.changestream.FullDocumentBeforeChange;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Options applicable to MongoDB <a href="https://docs.mongodb.com/manual/changeStreams/">Change Streams</a>. Intended
|
* Options applicable to MongoDB <a href="https://docs.mongodb.com/manual/changeStreams/">Change Streams</a>. Intended
|
||||||
@@ -40,6 +41,7 @@ import com.mongodb.client.model.changestream.FullDocument;
|
|||||||
*
|
*
|
||||||
* @author Christoph Strobl
|
* @author Christoph Strobl
|
||||||
* @author Mark Paluch
|
* @author Mark Paluch
|
||||||
|
* @author Myroslav Kosinskyi
|
||||||
* @since 2.1
|
* @since 2.1
|
||||||
*/
|
*/
|
||||||
public class ChangeStreamOptions {
|
public class ChangeStreamOptions {
|
||||||
@@ -47,6 +49,7 @@ public class ChangeStreamOptions {
|
|||||||
private @Nullable Object filter;
|
private @Nullable Object filter;
|
||||||
private @Nullable BsonValue resumeToken;
|
private @Nullable BsonValue resumeToken;
|
||||||
private @Nullable FullDocument fullDocumentLookup;
|
private @Nullable FullDocument fullDocumentLookup;
|
||||||
|
private @Nullable FullDocumentBeforeChange fullDocumentBeforeChangeLookup;
|
||||||
private @Nullable Collation collation;
|
private @Nullable Collation collation;
|
||||||
private @Nullable Object resumeTimestamp;
|
private @Nullable Object resumeTimestamp;
|
||||||
private Resume resume = Resume.UNDEFINED;
|
private Resume resume = Resume.UNDEFINED;
|
||||||
@@ -74,6 +77,14 @@ public class ChangeStreamOptions {
|
|||||||
return Optional.ofNullable(fullDocumentLookup);
|
return Optional.ofNullable(fullDocumentLookup);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* @return {@link Optional#empty()} if not set.
|
||||||
|
* @since 4.0
|
||||||
|
*/
|
||||||
|
public Optional<FullDocumentBeforeChange> getFullDocumentBeforeChangeLookup() {
|
||||||
|
return Optional.ofNullable(fullDocumentBeforeChangeLookup);
|
||||||
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* @return {@link Optional#empty()} if not set.
|
* @return {@link Optional#empty()} if not set.
|
||||||
*/
|
*/
|
||||||
@@ -153,7 +164,7 @@ public class ChangeStreamOptions {
|
|||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public boolean equals(Object o) {
|
public boolean equals(@Nullable Object o) {
|
||||||
if (this == o)
|
if (this == o)
|
||||||
return true;
|
return true;
|
||||||
if (o == null || getClass() != o.getClass())
|
if (o == null || getClass() != o.getClass())
|
||||||
@@ -170,6 +181,9 @@ public class ChangeStreamOptions {
|
|||||||
if (!ObjectUtils.nullSafeEquals(this.fullDocumentLookup, that.fullDocumentLookup)) {
|
if (!ObjectUtils.nullSafeEquals(this.fullDocumentLookup, that.fullDocumentLookup)) {
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
|
if (!ObjectUtils.nullSafeEquals(this.fullDocumentBeforeChangeLookup, that.fullDocumentBeforeChangeLookup)) {
|
||||||
|
return false;
|
||||||
|
}
|
||||||
if (!ObjectUtils.nullSafeEquals(this.collation, that.collation)) {
|
if (!ObjectUtils.nullSafeEquals(this.collation, that.collation)) {
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
@@ -184,6 +198,7 @@ public class ChangeStreamOptions {
|
|||||||
int result = ObjectUtils.nullSafeHashCode(filter);
|
int result = ObjectUtils.nullSafeHashCode(filter);
|
||||||
result = 31 * result + ObjectUtils.nullSafeHashCode(resumeToken);
|
result = 31 * result + ObjectUtils.nullSafeHashCode(resumeToken);
|
||||||
result = 31 * result + ObjectUtils.nullSafeHashCode(fullDocumentLookup);
|
result = 31 * result + ObjectUtils.nullSafeHashCode(fullDocumentLookup);
|
||||||
|
result = 31 * result + ObjectUtils.nullSafeHashCode(fullDocumentBeforeChangeLookup);
|
||||||
result = 31 * result + ObjectUtils.nullSafeHashCode(collation);
|
result = 31 * result + ObjectUtils.nullSafeHashCode(collation);
|
||||||
result = 31 * result + ObjectUtils.nullSafeHashCode(resumeTimestamp);
|
result = 31 * result + ObjectUtils.nullSafeHashCode(resumeTimestamp);
|
||||||
result = 31 * result + ObjectUtils.nullSafeHashCode(resume);
|
result = 31 * result + ObjectUtils.nullSafeHashCode(resume);
|
||||||
@@ -220,6 +235,7 @@ public class ChangeStreamOptions {
|
|||||||
private @Nullable Object filter;
|
private @Nullable Object filter;
|
||||||
private @Nullable BsonValue resumeToken;
|
private @Nullable BsonValue resumeToken;
|
||||||
private @Nullable FullDocument fullDocumentLookup;
|
private @Nullable FullDocument fullDocumentLookup;
|
||||||
|
private @Nullable FullDocumentBeforeChange fullDocumentBeforeChangeLookup;
|
||||||
private @Nullable Collation collation;
|
private @Nullable Collation collation;
|
||||||
private @Nullable Object resumeTimestamp;
|
private @Nullable Object resumeTimestamp;
|
||||||
private Resume resume = Resume.UNDEFINED;
|
private Resume resume = Resume.UNDEFINED;
|
||||||
@@ -322,6 +338,32 @@ public class ChangeStreamOptions {
|
|||||||
return this;
|
return this;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Set the {@link FullDocumentBeforeChange} lookup to use.
|
||||||
|
*
|
||||||
|
* @param lookup must not be {@literal null}.
|
||||||
|
* @return this.
|
||||||
|
* @since 4.0
|
||||||
|
*/
|
||||||
|
public ChangeStreamOptionsBuilder fullDocumentBeforeChangeLookup(FullDocumentBeforeChange lookup) {
|
||||||
|
|
||||||
|
Assert.notNull(lookup, "Lookup must not be null");
|
||||||
|
|
||||||
|
this.fullDocumentBeforeChangeLookup = lookup;
|
||||||
|
return this;
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Return the full document before being changed if it is available.
|
||||||
|
*
|
||||||
|
* @return this.
|
||||||
|
* @since 4.0
|
||||||
|
* @see #fullDocumentBeforeChangeLookup(FullDocumentBeforeChange)
|
||||||
|
*/
|
||||||
|
public ChangeStreamOptionsBuilder returnFullDocumentBeforeChange() {
|
||||||
|
return fullDocumentBeforeChangeLookup(FullDocumentBeforeChange.WHEN_AVAILABLE);
|
||||||
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Set the cluster time to resume from.
|
* Set the cluster time to resume from.
|
||||||
*
|
*
|
||||||
@@ -391,6 +433,7 @@ public class ChangeStreamOptions {
|
|||||||
options.filter = this.filter;
|
options.filter = this.filter;
|
||||||
options.resumeToken = this.resumeToken;
|
options.resumeToken = this.resumeToken;
|
||||||
options.fullDocumentLookup = this.fullDocumentLookup;
|
options.fullDocumentLookup = this.fullDocumentLookup;
|
||||||
|
options.fullDocumentBeforeChangeLookup = this.fullDocumentBeforeChangeLookup;
|
||||||
options.collation = this.collation;
|
options.collation = this.collation;
|
||||||
options.resumeTimestamp = this.resumeTimestamp;
|
options.resumeTimestamp = this.resumeTimestamp;
|
||||||
options.resume = this.resume;
|
options.resume = this.resume;
|
||||||
|
|||||||
@@ -1,5 +1,5 @@
|
|||||||
/*
|
/*
|
||||||
* Copyright 2010-2022 the original author or authors.
|
* Copyright 2010-2023 the original author or authors.
|
||||||
*
|
*
|
||||||
* Licensed under the Apache License, Version 2.0 (the "License");
|
* Licensed under the Apache License, Version 2.0 (the "License");
|
||||||
* you may not use this file except in compliance with the License.
|
* you may not use this file except in compliance with the License.
|
||||||
|
|||||||
@@ -1,5 +1,5 @@
|
|||||||
/*
|
/*
|
||||||
* Copyright 2010-2022 the original author or authors.
|
* Copyright 2010-2023 the original author or authors.
|
||||||
*
|
*
|
||||||
* Licensed under the Apache License, Version 2.0 (the "License");
|
* Licensed under the Apache License, Version 2.0 (the "License");
|
||||||
* you may not use this file except in compliance with the License.
|
* you may not use this file except in compliance with the License.
|
||||||
@@ -26,6 +26,7 @@ import org.springframework.data.mongodb.core.validation.Validator;
|
|||||||
import org.springframework.data.util.Optionals;
|
import org.springframework.data.util.Optionals;
|
||||||
import org.springframework.lang.Nullable;
|
import org.springframework.lang.Nullable;
|
||||||
import org.springframework.util.Assert;
|
import org.springframework.util.Assert;
|
||||||
|
import org.springframework.util.ObjectUtils;
|
||||||
|
|
||||||
import com.mongodb.client.model.ValidationAction;
|
import com.mongodb.client.model.ValidationAction;
|
||||||
import com.mongodb.client.model.ValidationLevel;
|
import com.mongodb.client.model.ValidationLevel;
|
||||||
@@ -46,10 +47,11 @@ public class CollectionOptions {
|
|||||||
private @Nullable Collation collation;
|
private @Nullable Collation collation;
|
||||||
private ValidationOptions validationOptions;
|
private ValidationOptions validationOptions;
|
||||||
private @Nullable TimeSeriesOptions timeSeriesOptions;
|
private @Nullable TimeSeriesOptions timeSeriesOptions;
|
||||||
|
private @Nullable CollectionChangeStreamOptions changeStreamOptions;
|
||||||
|
|
||||||
private CollectionOptions(@Nullable Long size, @Nullable Long maxDocuments, @Nullable Boolean capped,
|
private CollectionOptions(@Nullable Long size, @Nullable Long maxDocuments, @Nullable Boolean capped,
|
||||||
@Nullable Collation collation, ValidationOptions validationOptions,
|
@Nullable Collation collation, ValidationOptions validationOptions, @Nullable TimeSeriesOptions timeSeriesOptions,
|
||||||
@Nullable TimeSeriesOptions timeSeriesOptions) {
|
@Nullable CollectionChangeStreamOptions changeStreamOptions) {
|
||||||
|
|
||||||
this.maxDocuments = maxDocuments;
|
this.maxDocuments = maxDocuments;
|
||||||
this.size = size;
|
this.size = size;
|
||||||
@@ -57,6 +59,7 @@ public class CollectionOptions {
|
|||||||
this.collation = collation;
|
this.collation = collation;
|
||||||
this.validationOptions = validationOptions;
|
this.validationOptions = validationOptions;
|
||||||
this.timeSeriesOptions = timeSeriesOptions;
|
this.timeSeriesOptions = timeSeriesOptions;
|
||||||
|
this.changeStreamOptions = changeStreamOptions;
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
@@ -70,7 +73,7 @@ public class CollectionOptions {
|
|||||||
|
|
||||||
Assert.notNull(collation, "Collation must not be null");
|
Assert.notNull(collation, "Collation must not be null");
|
||||||
|
|
||||||
return new CollectionOptions(null, null, null, collation, ValidationOptions.none(), null);
|
return new CollectionOptions(null, null, null, collation, ValidationOptions.none(), null, null);
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
@@ -80,7 +83,7 @@ public class CollectionOptions {
|
|||||||
* @since 2.0
|
* @since 2.0
|
||||||
*/
|
*/
|
||||||
public static CollectionOptions empty() {
|
public static CollectionOptions empty() {
|
||||||
return new CollectionOptions(null, null, null, null, ValidationOptions.none(), null);
|
return new CollectionOptions(null, null, null, null, ValidationOptions.none(), null, null);
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
@@ -97,6 +100,18 @@ public class CollectionOptions {
|
|||||||
return empty().timeSeries(TimeSeriesOptions.timeSeries(timeField));
|
return empty().timeSeries(TimeSeriesOptions.timeSeries(timeField));
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Quick way to set up {@link CollectionOptions} for emitting (pre & post) change events.
|
||||||
|
*
|
||||||
|
* @return new instance of {@link CollectionOptions}.
|
||||||
|
* @see #changeStream(CollectionChangeStreamOptions)
|
||||||
|
* @see CollectionChangeStreamOptions#preAndPostImages(boolean)
|
||||||
|
* @since 4.0
|
||||||
|
*/
|
||||||
|
public static CollectionOptions emitChangedRevisions() {
|
||||||
|
return empty().changeStream(CollectionChangeStreamOptions.preAndPostImages(true));
|
||||||
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Create new {@link CollectionOptions} with already given settings and capped set to {@literal true}. <br />
|
* Create new {@link CollectionOptions} with already given settings and capped set to {@literal true}. <br />
|
||||||
* <strong>NOTE</strong> Using capped collections requires defining {@link #size(long)}.
|
* <strong>NOTE</strong> Using capped collections requires defining {@link #size(long)}.
|
||||||
@@ -105,7 +120,8 @@ public class CollectionOptions {
|
|||||||
* @since 2.0
|
* @since 2.0
|
||||||
*/
|
*/
|
||||||
public CollectionOptions capped() {
|
public CollectionOptions capped() {
|
||||||
return new CollectionOptions(size, maxDocuments, true, collation, validationOptions, null);
|
return new CollectionOptions(size, maxDocuments, true, collation, validationOptions, timeSeriesOptions,
|
||||||
|
changeStreamOptions);
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
@@ -116,7 +132,8 @@ public class CollectionOptions {
|
|||||||
* @since 2.0
|
* @since 2.0
|
||||||
*/
|
*/
|
||||||
public CollectionOptions maxDocuments(long maxDocuments) {
|
public CollectionOptions maxDocuments(long maxDocuments) {
|
||||||
return new CollectionOptions(size, maxDocuments, capped, collation, validationOptions, timeSeriesOptions);
|
return new CollectionOptions(size, maxDocuments, capped, collation, validationOptions, timeSeriesOptions,
|
||||||
|
changeStreamOptions);
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
@@ -127,7 +144,8 @@ public class CollectionOptions {
|
|||||||
* @since 2.0
|
* @since 2.0
|
||||||
*/
|
*/
|
||||||
public CollectionOptions size(long size) {
|
public CollectionOptions size(long size) {
|
||||||
return new CollectionOptions(size, maxDocuments, capped, collation, validationOptions, timeSeriesOptions);
|
return new CollectionOptions(size, maxDocuments, capped, collation, validationOptions, timeSeriesOptions,
|
||||||
|
changeStreamOptions);
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
@@ -138,7 +156,8 @@ public class CollectionOptions {
|
|||||||
* @since 2.0
|
* @since 2.0
|
||||||
*/
|
*/
|
||||||
public CollectionOptions collation(@Nullable Collation collation) {
|
public CollectionOptions collation(@Nullable Collation collation) {
|
||||||
return new CollectionOptions(size, maxDocuments, capped, collation, validationOptions, timeSeriesOptions);
|
return new CollectionOptions(size, maxDocuments, capped, collation, validationOptions, timeSeriesOptions,
|
||||||
|
changeStreamOptions);
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
@@ -258,7 +277,8 @@ public class CollectionOptions {
|
|||||||
public CollectionOptions validation(ValidationOptions validationOptions) {
|
public CollectionOptions validation(ValidationOptions validationOptions) {
|
||||||
|
|
||||||
Assert.notNull(validationOptions, "ValidationOptions must not be null");
|
Assert.notNull(validationOptions, "ValidationOptions must not be null");
|
||||||
return new CollectionOptions(size, maxDocuments, capped, collation, validationOptions, timeSeriesOptions);
|
return new CollectionOptions(size, maxDocuments, capped, collation, validationOptions, timeSeriesOptions,
|
||||||
|
changeStreamOptions);
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
@@ -271,7 +291,22 @@ public class CollectionOptions {
|
|||||||
public CollectionOptions timeSeries(TimeSeriesOptions timeSeriesOptions) {
|
public CollectionOptions timeSeries(TimeSeriesOptions timeSeriesOptions) {
|
||||||
|
|
||||||
Assert.notNull(timeSeriesOptions, "TimeSeriesOptions must not be null");
|
Assert.notNull(timeSeriesOptions, "TimeSeriesOptions must not be null");
|
||||||
return new CollectionOptions(size, maxDocuments, capped, collation, validationOptions, timeSeriesOptions);
|
return new CollectionOptions(size, maxDocuments, capped, collation, validationOptions, timeSeriesOptions,
|
||||||
|
changeStreamOptions);
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Create new {@link CollectionOptions} with the given {@link TimeSeriesOptions}.
|
||||||
|
*
|
||||||
|
* @param changeStreamOptions must not be {@literal null}.
|
||||||
|
* @return new instance of {@link CollectionOptions}.
|
||||||
|
* @since 3.3
|
||||||
|
*/
|
||||||
|
public CollectionOptions changeStream(CollectionChangeStreamOptions changeStreamOptions) {
|
||||||
|
|
||||||
|
Assert.notNull(changeStreamOptions, "ChangeStreamOptions must not be null");
|
||||||
|
return new CollectionOptions(size, maxDocuments, capped, collation, validationOptions, timeSeriesOptions,
|
||||||
|
changeStreamOptions);
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
@@ -332,6 +367,70 @@ public class CollectionOptions {
|
|||||||
return Optional.ofNullable(timeSeriesOptions);
|
return Optional.ofNullable(timeSeriesOptions);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Get the {@link CollectionChangeStreamOptions} if available.
|
||||||
|
*
|
||||||
|
* @return {@link Optional#empty()} if not specified.
|
||||||
|
* @since 4.0
|
||||||
|
*/
|
||||||
|
public Optional<CollectionChangeStreamOptions> getChangeStreamOptions() {
|
||||||
|
return Optional.ofNullable(changeStreamOptions);
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public String toString() {
|
||||||
|
return "CollectionOptions{" + "maxDocuments=" + maxDocuments + ", size=" + size + ", capped=" + capped
|
||||||
|
+ ", collation=" + collation + ", validationOptions=" + validationOptions + ", timeSeriesOptions="
|
||||||
|
+ timeSeriesOptions + ", changeStreamOptions=" + changeStreamOptions + ", disableValidation="
|
||||||
|
+ disableValidation() + ", strictValidation=" + strictValidation() + ", moderateValidation="
|
||||||
|
+ moderateValidation() + ", warnOnValidationError=" + warnOnValidationError() + ", failOnValidationError="
|
||||||
|
+ failOnValidationError() + '}';
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public boolean equals(@Nullable Object o) {
|
||||||
|
if (this == o) {
|
||||||
|
return true;
|
||||||
|
}
|
||||||
|
if (o == null || getClass() != o.getClass()) {
|
||||||
|
return false;
|
||||||
|
}
|
||||||
|
|
||||||
|
CollectionOptions that = (CollectionOptions) o;
|
||||||
|
|
||||||
|
if (!ObjectUtils.nullSafeEquals(maxDocuments, that.maxDocuments)) {
|
||||||
|
return false;
|
||||||
|
}
|
||||||
|
if (!ObjectUtils.nullSafeEquals(size, that.size)) {
|
||||||
|
return false;
|
||||||
|
}
|
||||||
|
if (!ObjectUtils.nullSafeEquals(capped, that.capped)) {
|
||||||
|
return false;
|
||||||
|
}
|
||||||
|
if (!ObjectUtils.nullSafeEquals(collation, that.collation)) {
|
||||||
|
return false;
|
||||||
|
}
|
||||||
|
if (!ObjectUtils.nullSafeEquals(validationOptions, that.validationOptions)) {
|
||||||
|
return false;
|
||||||
|
}
|
||||||
|
if (!ObjectUtils.nullSafeEquals(timeSeriesOptions, that.timeSeriesOptions)) {
|
||||||
|
return false;
|
||||||
|
}
|
||||||
|
return ObjectUtils.nullSafeEquals(changeStreamOptions, that.changeStreamOptions);
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public int hashCode() {
|
||||||
|
int result = ObjectUtils.nullSafeHashCode(maxDocuments);
|
||||||
|
result = 31 * result + ObjectUtils.nullSafeHashCode(size);
|
||||||
|
result = 31 * result + ObjectUtils.nullSafeHashCode(capped);
|
||||||
|
result = 31 * result + ObjectUtils.nullSafeHashCode(collation);
|
||||||
|
result = 31 * result + ObjectUtils.nullSafeHashCode(validationOptions);
|
||||||
|
result = 31 * result + ObjectUtils.nullSafeHashCode(timeSeriesOptions);
|
||||||
|
result = 31 * result + ObjectUtils.nullSafeHashCode(changeStreamOptions);
|
||||||
|
return result;
|
||||||
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Encapsulation of ValidationOptions options.
|
* Encapsulation of ValidationOptions options.
|
||||||
*
|
*
|
||||||
@@ -426,6 +525,92 @@ public class CollectionOptions {
|
|||||||
boolean isEmpty() {
|
boolean isEmpty() {
|
||||||
return !Optionals.isAnyPresent(getValidator(), getValidationAction(), getValidationLevel());
|
return !Optionals.isAnyPresent(getValidator(), getValidationAction(), getValidationLevel());
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public String toString() {
|
||||||
|
|
||||||
|
return "ValidationOptions{" + "validator=" + validator + ", validationLevel=" + validationLevel
|
||||||
|
+ ", validationAction=" + validationAction + '}';
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public boolean equals(@Nullable Object o) {
|
||||||
|
if (this == o) {
|
||||||
|
return true;
|
||||||
|
}
|
||||||
|
if (o == null || getClass() != o.getClass()) {
|
||||||
|
return false;
|
||||||
|
}
|
||||||
|
|
||||||
|
ValidationOptions that = (ValidationOptions) o;
|
||||||
|
|
||||||
|
if (!ObjectUtils.nullSafeEquals(validator, that.validator)) {
|
||||||
|
return false;
|
||||||
|
}
|
||||||
|
if (validationLevel != that.validationLevel)
|
||||||
|
return false;
|
||||||
|
return validationAction == that.validationAction;
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public int hashCode() {
|
||||||
|
int result = ObjectUtils.nullSafeHashCode(validator);
|
||||||
|
result = 31 * result + ObjectUtils.nullSafeHashCode(validationLevel);
|
||||||
|
result = 31 * result + ObjectUtils.nullSafeHashCode(validationAction);
|
||||||
|
return result;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Encapsulation of options applied to define collections change stream behaviour.
|
||||||
|
*
|
||||||
|
* @author Christoph Strobl
|
||||||
|
* @since 4.0
|
||||||
|
*/
|
||||||
|
public static class CollectionChangeStreamOptions {
|
||||||
|
|
||||||
|
private final boolean preAndPostImages;
|
||||||
|
|
||||||
|
private CollectionChangeStreamOptions(boolean emitChangedRevisions) {
|
||||||
|
this.preAndPostImages = emitChangedRevisions;
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Output the version of a document before and after changes (the document pre- and post-images).
|
||||||
|
*
|
||||||
|
* @return new instance of {@link CollectionChangeStreamOptions}.
|
||||||
|
*/
|
||||||
|
public static CollectionChangeStreamOptions preAndPostImages(boolean emitChangedRevisions) {
|
||||||
|
return new CollectionChangeStreamOptions(true);
|
||||||
|
}
|
||||||
|
|
||||||
|
public boolean getPreAndPostImages() {
|
||||||
|
return preAndPostImages;
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public String toString() {
|
||||||
|
return "CollectionChangeStreamOptions{" + "preAndPostImages=" + preAndPostImages + '}';
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public boolean equals(@Nullable Object o) {
|
||||||
|
if (this == o) {
|
||||||
|
return true;
|
||||||
|
}
|
||||||
|
if (o == null || getClass() != o.getClass()) {
|
||||||
|
return false;
|
||||||
|
}
|
||||||
|
|
||||||
|
CollectionChangeStreamOptions that = (CollectionChangeStreamOptions) o;
|
||||||
|
|
||||||
|
return preAndPostImages == that.preAndPostImages;
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public int hashCode() {
|
||||||
|
return (preAndPostImages ? 1 : 0);
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
@@ -511,5 +696,40 @@ public class CollectionOptions {
|
|||||||
public GranularityDefinition getGranularity() {
|
public GranularityDefinition getGranularity() {
|
||||||
return granularity;
|
return granularity;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public String toString() {
|
||||||
|
|
||||||
|
return "TimeSeriesOptions{" + "timeField='" + timeField + '\'' + ", metaField='" + metaField + '\''
|
||||||
|
+ ", granularity=" + granularity + '}';
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public boolean equals(@Nullable Object o) {
|
||||||
|
if (this == o) {
|
||||||
|
return true;
|
||||||
|
}
|
||||||
|
if (o == null || getClass() != o.getClass()) {
|
||||||
|
return false;
|
||||||
|
}
|
||||||
|
|
||||||
|
TimeSeriesOptions that = (TimeSeriesOptions) o;
|
||||||
|
|
||||||
|
if (!ObjectUtils.nullSafeEquals(timeField, that.timeField)) {
|
||||||
|
return false;
|
||||||
|
}
|
||||||
|
if (!ObjectUtils.nullSafeEquals(metaField, that.metaField)) {
|
||||||
|
return false;
|
||||||
|
}
|
||||||
|
return ObjectUtils.nullSafeEquals(granularity, that.granularity);
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public int hashCode() {
|
||||||
|
int result = ObjectUtils.nullSafeHashCode(timeField);
|
||||||
|
result = 31 * result + ObjectUtils.nullSafeHashCode(metaField);
|
||||||
|
result = 31 * result + ObjectUtils.nullSafeHashCode(granularity);
|
||||||
|
return result;
|
||||||
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -0,0 +1,61 @@
|
|||||||
|
/*
|
||||||
|
* Copyright 2023 the original author or authors.
|
||||||
|
*
|
||||||
|
* Licensed under the Apache License, Version 2.0 (the "License");
|
||||||
|
* you may not use this file except in compliance with the License.
|
||||||
|
* You may obtain a copy of the License at
|
||||||
|
*
|
||||||
|
* https://www.apache.org/licenses/LICENSE-2.0
|
||||||
|
*
|
||||||
|
* Unless required by applicable law or agreed to in writing, software
|
||||||
|
* distributed under the License is distributed on an "AS IS" BASIS,
|
||||||
|
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
||||||
|
* See the License for the specific language governing permissions and
|
||||||
|
* limitations under the License.
|
||||||
|
*/
|
||||||
|
package org.springframework.data.mongodb.core;
|
||||||
|
|
||||||
|
import org.springframework.util.Assert;
|
||||||
|
|
||||||
|
import com.mongodb.client.MongoCollection;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Interface for functional preparation of a {@link MongoCollection}.
|
||||||
|
*
|
||||||
|
* @author Mark Paluch
|
||||||
|
* @since 4.1
|
||||||
|
*/
|
||||||
|
public interface CollectionPreparer<T> {
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Returns a preparer that always returns its input collection.
|
||||||
|
*
|
||||||
|
* @return a preparer that always returns its input collection.
|
||||||
|
*/
|
||||||
|
static <T> CollectionPreparer<T> identity() {
|
||||||
|
return it -> it;
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Prepare the {@code collection}.
|
||||||
|
*
|
||||||
|
* @param collection the collection to prepare.
|
||||||
|
* @return the prepared collection.
|
||||||
|
*/
|
||||||
|
T prepare(T collection);
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Returns a composed {@code CollectionPreparer} that first applies this preparer to the collection, and then applies
|
||||||
|
* the {@code after} preparer to the result. If evaluation of either function throws an exception, it is relayed to
|
||||||
|
* the caller of the composed function.
|
||||||
|
*
|
||||||
|
* @param after the collection preparer to apply after this function is applied.
|
||||||
|
* @return a composed {@code CollectionPreparer} that first applies this preparer and then applies the {@code after}
|
||||||
|
* preparer.
|
||||||
|
*/
|
||||||
|
default CollectionPreparer<T> andThen(CollectionPreparer<T> after) {
|
||||||
|
Assert.notNull(after, "After CollectionPreparer must not be null");
|
||||||
|
return c -> after.prepare(prepare(c));
|
||||||
|
}
|
||||||
|
|
||||||
|
}
|
||||||
@@ -0,0 +1,182 @@
|
|||||||
|
/*
|
||||||
|
* Copyright 2023 the original author or authors.
|
||||||
|
*
|
||||||
|
* Licensed under the Apache License, Version 2.0 (the "License");
|
||||||
|
* you may not use this file except in compliance with the License.
|
||||||
|
* You may obtain a copy of the License at
|
||||||
|
*
|
||||||
|
* https://www.apache.org/licenses/LICENSE-2.0
|
||||||
|
*
|
||||||
|
* Unless required by applicable law or agreed to in writing, software
|
||||||
|
* distributed under the License is distributed on an "AS IS" BASIS,
|
||||||
|
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
||||||
|
* See the License for the specific language governing permissions and
|
||||||
|
* limitations under the License.
|
||||||
|
*/
|
||||||
|
package org.springframework.data.mongodb.core;
|
||||||
|
|
||||||
|
import java.util.Arrays;
|
||||||
|
import java.util.List;
|
||||||
|
import java.util.function.BiFunction;
|
||||||
|
import java.util.function.Function;
|
||||||
|
|
||||||
|
import org.bson.Document;
|
||||||
|
|
||||||
|
import com.mongodb.ReadConcern;
|
||||||
|
import com.mongodb.ReadPreference;
|
||||||
|
import com.mongodb.client.MongoCollection;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Support class for delegate implementations to apply {@link ReadConcern} and {@link ReadPreference} settings upon
|
||||||
|
* {@link CollectionPreparer preparing a collection}.
|
||||||
|
*
|
||||||
|
* @author Mark Paluch
|
||||||
|
* @since 4.1
|
||||||
|
*/
|
||||||
|
class CollectionPreparerSupport implements ReadConcernAware, ReadPreferenceAware {
|
||||||
|
|
||||||
|
private final List<Object> sources;
|
||||||
|
|
||||||
|
private CollectionPreparerSupport(List<Object> sources) {
|
||||||
|
this.sources = sources;
|
||||||
|
}
|
||||||
|
|
||||||
|
<T> T doPrepare(T collection, Function<T, ReadConcern> concernAccessor, BiFunction<T, ReadConcern, T> concernFunction,
|
||||||
|
Function<T, ReadPreference> preferenceAccessor, BiFunction<T, ReadPreference, T> preferenceFunction) {
|
||||||
|
|
||||||
|
T collectionToUse = collection;
|
||||||
|
|
||||||
|
for (Object source : sources) {
|
||||||
|
if (source instanceof ReadConcernAware rca && rca.hasReadConcern()) {
|
||||||
|
|
||||||
|
ReadConcern concern = rca.getReadConcern();
|
||||||
|
if (concernAccessor.apply(collectionToUse) != concern) {
|
||||||
|
collectionToUse = concernFunction.apply(collectionToUse, concern);
|
||||||
|
}
|
||||||
|
break;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
for (Object source : sources) {
|
||||||
|
if (source instanceof ReadPreferenceAware rpa && rpa.hasReadPreference()) {
|
||||||
|
|
||||||
|
ReadPreference preference = rpa.getReadPreference();
|
||||||
|
if (preferenceAccessor.apply(collectionToUse) != preference) {
|
||||||
|
collectionToUse = preferenceFunction.apply(collectionToUse, preference);
|
||||||
|
}
|
||||||
|
break;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
return collectionToUse;
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public boolean hasReadConcern() {
|
||||||
|
|
||||||
|
for (Object aware : sources) {
|
||||||
|
if (aware instanceof ReadConcernAware rca && rca.hasReadConcern()) {
|
||||||
|
return true;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
return false;
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public ReadConcern getReadConcern() {
|
||||||
|
|
||||||
|
for (Object aware : sources) {
|
||||||
|
if (aware instanceof ReadConcernAware rca && rca.hasReadConcern()) {
|
||||||
|
return rca.getReadConcern();
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
return null;
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public boolean hasReadPreference() {
|
||||||
|
|
||||||
|
for (Object aware : sources) {
|
||||||
|
if (aware instanceof ReadPreferenceAware rpa && rpa.hasReadPreference()) {
|
||||||
|
return true;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
return false;
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public ReadPreference getReadPreference() {
|
||||||
|
|
||||||
|
for (Object aware : sources) {
|
||||||
|
if (aware instanceof ReadPreferenceAware rpa && rpa.hasReadPreference()) {
|
||||||
|
return rpa.getReadPreference();
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
return null;
|
||||||
|
}
|
||||||
|
|
||||||
|
static class CollectionPreparerDelegate extends CollectionPreparerSupport
|
||||||
|
implements CollectionPreparer<MongoCollection<Document>> {
|
||||||
|
|
||||||
|
private CollectionPreparerDelegate(List<Object> sources) {
|
||||||
|
super(sources);
|
||||||
|
}
|
||||||
|
|
||||||
|
public static CollectionPreparerDelegate of(ReadPreferenceAware... awares) {
|
||||||
|
return of((Object[]) awares);
|
||||||
|
}
|
||||||
|
|
||||||
|
public static CollectionPreparerDelegate of(Object... mixedAwares) {
|
||||||
|
|
||||||
|
if (mixedAwares.length == 1 && mixedAwares[0] instanceof CollectionPreparerDelegate) {
|
||||||
|
return (CollectionPreparerDelegate) mixedAwares[0];
|
||||||
|
}
|
||||||
|
|
||||||
|
return new CollectionPreparerDelegate(Arrays.asList(mixedAwares));
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public MongoCollection<Document> prepare(MongoCollection<Document> collection) {
|
||||||
|
return doPrepare(collection, MongoCollection::getReadConcern, MongoCollection::withReadConcern,
|
||||||
|
MongoCollection::getReadPreference, MongoCollection::withReadPreference);
|
||||||
|
}
|
||||||
|
|
||||||
|
}
|
||||||
|
|
||||||
|
static class ReactiveCollectionPreparerDelegate extends CollectionPreparerSupport
|
||||||
|
implements CollectionPreparer<com.mongodb.reactivestreams.client.MongoCollection<Document>> {
|
||||||
|
|
||||||
|
private ReactiveCollectionPreparerDelegate(List<Object> sources) {
|
||||||
|
super(sources);
|
||||||
|
}
|
||||||
|
|
||||||
|
public static ReactiveCollectionPreparerDelegate of(ReadPreferenceAware... awares) {
|
||||||
|
return of((Object[]) awares);
|
||||||
|
}
|
||||||
|
|
||||||
|
public static ReactiveCollectionPreparerDelegate of(Object... mixedAwares) {
|
||||||
|
|
||||||
|
if (mixedAwares.length == 1 && mixedAwares[0] instanceof CollectionPreparerDelegate) {
|
||||||
|
return (ReactiveCollectionPreparerDelegate) mixedAwares[0];
|
||||||
|
}
|
||||||
|
|
||||||
|
return new ReactiveCollectionPreparerDelegate(Arrays.asList(mixedAwares));
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public com.mongodb.reactivestreams.client.MongoCollection<Document> prepare(
|
||||||
|
com.mongodb.reactivestreams.client.MongoCollection<Document> collection) {
|
||||||
|
return doPrepare(collection, //
|
||||||
|
com.mongodb.reactivestreams.client.MongoCollection::getReadConcern,
|
||||||
|
com.mongodb.reactivestreams.client.MongoCollection::withReadConcern,
|
||||||
|
com.mongodb.reactivestreams.client.MongoCollection::getReadPreference,
|
||||||
|
com.mongodb.reactivestreams.client.MongoCollection::withReadPreference);
|
||||||
|
}
|
||||||
|
|
||||||
|
}
|
||||||
|
|
||||||
|
}
|
||||||
@@ -1,5 +1,5 @@
|
|||||||
/*
|
/*
|
||||||
* Copyright 2019-2022 the original author or authors.
|
* Copyright 2019-2023 the original author or authors.
|
||||||
*
|
*
|
||||||
* Licensed under the Apache License, Version 2.0 (the "License");
|
* Licensed under the Apache License, Version 2.0 (the "License");
|
||||||
* you may not use this file except in compliance with the License.
|
* you may not use this file except in compliance with the License.
|
||||||
@@ -23,8 +23,8 @@ import java.util.List;
|
|||||||
import java.util.Map;
|
import java.util.Map;
|
||||||
|
|
||||||
import org.bson.Document;
|
import org.bson.Document;
|
||||||
|
|
||||||
import org.springframework.data.geo.Point;
|
import org.springframework.data.geo.Point;
|
||||||
|
import org.springframework.data.mongodb.core.query.MetricConversion;
|
||||||
import org.springframework.lang.Nullable;
|
import org.springframework.lang.Nullable;
|
||||||
import org.springframework.util.ObjectUtils;
|
import org.springframework.util.ObjectUtils;
|
||||||
|
|
||||||
@@ -38,7 +38,7 @@ import org.springframework.util.ObjectUtils;
|
|||||||
*/
|
*/
|
||||||
class CountQuery {
|
class CountQuery {
|
||||||
|
|
||||||
private Document source;
|
private final Document source;
|
||||||
|
|
||||||
private CountQuery(Document source) {
|
private CountQuery(Document source) {
|
||||||
this.source = source;
|
this.source = source;
|
||||||
@@ -101,7 +101,7 @@ class CountQuery {
|
|||||||
}
|
}
|
||||||
|
|
||||||
if (valueToInspect instanceof Collection) {
|
if (valueToInspect instanceof Collection) {
|
||||||
return requiresRewrite((Collection) valueToInspect);
|
return requiresRewrite((Collection<?>) valueToInspect);
|
||||||
}
|
}
|
||||||
|
|
||||||
return false;
|
return false;
|
||||||
@@ -157,12 +157,14 @@ class CountQuery {
|
|||||||
* @param $and potentially existing {@code $and} condition.
|
* @param $and potentially existing {@code $and} condition.
|
||||||
* @return the rewritten query {@link Document}.
|
* @return the rewritten query {@link Document}.
|
||||||
*/
|
*/
|
||||||
|
@SuppressWarnings("unchecked")
|
||||||
private static Document createGeoWithin(String key, Document source, @Nullable Object $and) {
|
private static Document createGeoWithin(String key, Document source, @Nullable Object $and) {
|
||||||
|
|
||||||
boolean spheric = source.containsKey("$nearSphere");
|
boolean spheric = source.containsKey("$nearSphere");
|
||||||
Object $near = spheric ? source.get("$nearSphere") : source.get("$near");
|
Object $near = spheric ? source.get("$nearSphere") : source.get("$near");
|
||||||
|
|
||||||
Number maxDistance = source.containsKey("$maxDistance") ? (Number) source.get("$maxDistance") : Double.MAX_VALUE;
|
Number maxDistance = getMaxDistance(source, $near, spheric);
|
||||||
|
|
||||||
List<Object> $centerMax = Arrays.asList(toCenterCoordinates($near), maxDistance);
|
List<Object> $centerMax = Arrays.asList(toCenterCoordinates($near), maxDistance);
|
||||||
Document $geoWithinMax = new Document("$geoWithin",
|
Document $geoWithinMax = new Document("$geoWithin",
|
||||||
new Document(spheric ? "$centerSphere" : "$center", $centerMax));
|
new Document(spheric ? "$centerSphere" : "$center", $centerMax));
|
||||||
@@ -176,23 +178,51 @@ class CountQuery {
|
|||||||
Document $geoWithinMin = new Document("$geoWithin",
|
Document $geoWithinMin = new Document("$geoWithin",
|
||||||
new Document(spheric ? "$centerSphere" : "$center", $centerMin));
|
new Document(spheric ? "$centerSphere" : "$center", $centerMin));
|
||||||
|
|
||||||
List<Document> criteria = new ArrayList<>();
|
List<Document> criteria;
|
||||||
|
|
||||||
if ($and != null) {
|
if ($and != null) {
|
||||||
if ($and instanceof Collection) {
|
if ($and instanceof Collection) {
|
||||||
criteria.addAll((Collection) $and);
|
Collection<Document> andElements = (Collection<Document>) $and;
|
||||||
|
criteria = new ArrayList<>(andElements.size() + 2);
|
||||||
|
criteria.addAll(andElements);
|
||||||
} else {
|
} else {
|
||||||
throw new IllegalArgumentException(
|
throw new IllegalArgumentException(
|
||||||
"Cannot rewrite query as it contains an '$and' element that is not a Collection: Offending element: "
|
"Cannot rewrite query as it contains an '$and' element that is not a Collection: Offending element: "
|
||||||
+ $and);
|
+ $and);
|
||||||
}
|
}
|
||||||
|
} else {
|
||||||
|
criteria = new ArrayList<>(2);
|
||||||
}
|
}
|
||||||
|
|
||||||
criteria.add(new Document("$nor", Collections.singletonList(new Document(key, $geoWithinMin))));
|
criteria.add(new Document("$nor", Collections.singletonList(new Document(key, $geoWithinMin))));
|
||||||
criteria.add(new Document(key, $geoWithinMax));
|
criteria.add(new Document(key, $geoWithinMax));
|
||||||
|
|
||||||
return new Document("$and", criteria);
|
return new Document("$and", criteria);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
private static Number getMaxDistance(Document source, Object $near, boolean spheric) {
|
||||||
|
|
||||||
|
Number maxDistance = Double.MAX_VALUE;
|
||||||
|
|
||||||
|
if (source.containsKey("$maxDistance")) { // legacy coordinate pair
|
||||||
|
return (Number) source.get("$maxDistance");
|
||||||
|
}
|
||||||
|
|
||||||
|
if ($near instanceof Document nearDoc) {
|
||||||
|
|
||||||
|
if (nearDoc.containsKey("$maxDistance")) {
|
||||||
|
|
||||||
|
maxDistance = (Number) nearDoc.get("$maxDistance");
|
||||||
|
// geojson is in Meters but we need radians x/(6378.1*1000)
|
||||||
|
if (spheric && nearDoc.containsKey("$geometry")) {
|
||||||
|
maxDistance = MetricConversion.metersToRadians(maxDistance.doubleValue());
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
return maxDistance;
|
||||||
|
}
|
||||||
|
|
||||||
private static boolean containsNear(Document source) {
|
private static boolean containsNear(Document source) {
|
||||||
return source.containsKey("$near") || source.containsKey("$nearSphere");
|
return source.containsKey("$near") || source.containsKey("$nearSphere");
|
||||||
}
|
}
|
||||||
@@ -216,10 +246,16 @@ class CountQuery {
|
|||||||
return Arrays.asList(((Point) value).getX(), ((Point) value).getY());
|
return Arrays.asList(((Point) value).getX(), ((Point) value).getY());
|
||||||
}
|
}
|
||||||
|
|
||||||
if (value instanceof Document && ((Document) value).containsKey("x")) {
|
if (value instanceof Document document) {
|
||||||
|
|
||||||
Document point = (Document) value;
|
if (document.containsKey("x")) {
|
||||||
return Arrays.asList(point.get("x"), point.get("y"));
|
return Arrays.asList(document.get("x"), document.get("y"));
|
||||||
|
}
|
||||||
|
|
||||||
|
if (document.containsKey("$geometry")) {
|
||||||
|
Document geoJsonPoint = document.get("$geometry", Document.class);
|
||||||
|
return geoJsonPoint.get("coordinates");
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
return value;
|
return value;
|
||||||
|
|||||||
@@ -1,5 +1,5 @@
|
|||||||
/*
|
/*
|
||||||
* Copyright 2002-2022 the original author or authors.
|
* Copyright 2002-2023 the original author or authors.
|
||||||
*
|
*
|
||||||
* Licensed under the Apache License, Version 2.0 (the "License");
|
* Licensed under the Apache License, Version 2.0 (the "License");
|
||||||
* you may not use this file except in compliance with the License.
|
* you may not use this file except in compliance with the License.
|
||||||
|
|||||||
@@ -1,5 +1,5 @@
|
|||||||
/*
|
/*
|
||||||
* Copyright 2010-2022 the original author or authors.
|
* Copyright 2010-2023 the original author or authors.
|
||||||
*
|
*
|
||||||
* Licensed under the Apache License, Version 2.0 (the "License");
|
* Licensed under the Apache License, Version 2.0 (the "License");
|
||||||
* you may not use this file except in compliance with the License.
|
* you may not use this file except in compliance with the License.
|
||||||
|
|||||||
@@ -1,5 +1,5 @@
|
|||||||
/*
|
/*
|
||||||
* Copyright 2015-2022 the original author or authors.
|
* Copyright 2015-2023 the original author or authors.
|
||||||
*
|
*
|
||||||
* Licensed under the Apache License, Version 2.0 (the "License");
|
* Licensed under the Apache License, Version 2.0 (the "License");
|
||||||
* you may not use this file except in compliance with the License.
|
* you may not use this file except in compliance with the License.
|
||||||
@@ -550,7 +550,7 @@ class DefaultBulkOperations implements BulkOperations {
|
|||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public boolean equals(Object o) {
|
public boolean equals(@Nullable Object o) {
|
||||||
if (this == o)
|
if (this == o)
|
||||||
return true;
|
return true;
|
||||||
if (o == null || getClass() != o.getClass())
|
if (o == null || getClass() != o.getClass())
|
||||||
@@ -619,7 +619,7 @@ class DefaultBulkOperations implements BulkOperations {
|
|||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public boolean equals(Object o) {
|
public boolean equals(@Nullable Object o) {
|
||||||
if (this == o)
|
if (this == o)
|
||||||
return true;
|
return true;
|
||||||
if (o == null || getClass() != o.getClass())
|
if (o == null || getClass() != o.getClass())
|
||||||
|
|||||||
@@ -1,5 +1,5 @@
|
|||||||
/*
|
/*
|
||||||
* Copyright 2011-2022 the original author or authors.
|
* Copyright 2011-2023 the original author or authors.
|
||||||
*
|
*
|
||||||
* Licensed under the Apache License, Version 2.0 (the "License");
|
* Licensed under the Apache License, Version 2.0 (the "License");
|
||||||
* you may not use this file except in compliance with the License.
|
* you may not use this file except in compliance with the License.
|
||||||
@@ -172,7 +172,8 @@ public class DefaultIndexOperations implements IndexOperations {
|
|||||||
|
|
||||||
private List<IndexInfo> getIndexData(MongoCursor<Document> cursor) {
|
private List<IndexInfo> getIndexData(MongoCursor<Document> cursor) {
|
||||||
|
|
||||||
List<IndexInfo> indexInfoList = new ArrayList<>();
|
int available = cursor.available();
|
||||||
|
List<IndexInfo> indexInfoList = available > 0 ? new ArrayList<>(available) : new ArrayList<>();
|
||||||
|
|
||||||
while (cursor.hasNext()) {
|
while (cursor.hasNext()) {
|
||||||
|
|
||||||
|
|||||||
@@ -1,5 +1,5 @@
|
|||||||
/*
|
/*
|
||||||
* Copyright 2016-2022 the original author or authors.
|
* Copyright 2016-2023 the original author or authors.
|
||||||
*
|
*
|
||||||
* Licensed under the Apache License, Version 2.0 (the "License");
|
* Licensed under the Apache License, Version 2.0 (the "License");
|
||||||
* you may not use this file except in compliance with the License.
|
* you may not use this file except in compliance with the License.
|
||||||
|
|||||||
@@ -1,5 +1,5 @@
|
|||||||
/*
|
/*
|
||||||
* Copyright 2016-2022 the original author or authors.
|
* Copyright 2016-2023 the original author or authors.
|
||||||
*
|
*
|
||||||
* Licensed under the Apache License, Version 2.0 (the "License");
|
* Licensed under the Apache License, Version 2.0 (the "License");
|
||||||
* you may not use this file except in compliance with the License.
|
* you may not use this file except in compliance with the License.
|
||||||
|
|||||||
@@ -1,5 +1,5 @@
|
|||||||
/*
|
/*
|
||||||
* Copyright 2014-2022 the original author or authors.
|
* Copyright 2014-2023 the original author or authors.
|
||||||
*
|
*
|
||||||
* Licensed under the Apache License, Version 2.0 (the "License");
|
* Licensed under the Apache License, Version 2.0 (the "License");
|
||||||
* you may not use this file except in compliance with the License.
|
* you may not use this file except in compliance with the License.
|
||||||
@@ -31,7 +31,6 @@ import org.bson.types.ObjectId;
|
|||||||
import org.springframework.dao.DataAccessException;
|
import org.springframework.dao.DataAccessException;
|
||||||
import org.springframework.data.mongodb.core.script.ExecutableMongoScript;
|
import org.springframework.data.mongodb.core.script.ExecutableMongoScript;
|
||||||
import org.springframework.data.mongodb.core.script.NamedMongoScript;
|
import org.springframework.data.mongodb.core.script.NamedMongoScript;
|
||||||
import org.springframework.lang.Nullable;
|
|
||||||
import org.springframework.util.Assert;
|
import org.springframework.util.Assert;
|
||||||
import org.springframework.util.CollectionUtils;
|
import org.springframework.util.CollectionUtils;
|
||||||
import org.springframework.util.ObjectUtils;
|
import org.springframework.util.ObjectUtils;
|
||||||
|
|||||||
@@ -1,5 +1,5 @@
|
|||||||
/*
|
/*
|
||||||
* Copyright 2015-2022 the original author or authors.
|
* Copyright 2015-2023 the original author or authors.
|
||||||
*
|
*
|
||||||
* Licensed under the Apache License, Version 2.0 (the "License");
|
* Licensed under the Apache License, Version 2.0 (the "License");
|
||||||
* you may not use this file except in compliance with the License.
|
* you may not use this file except in compliance with the License.
|
||||||
|
|||||||
@@ -1,5 +1,5 @@
|
|||||||
/*
|
/*
|
||||||
* Copyright 2010-2022 the original author or authors.
|
* Copyright 2010-2023 the original author or authors.
|
||||||
*
|
*
|
||||||
* Licensed under the Apache License, Version 2.0 (the "License");
|
* Licensed under the Apache License, Version 2.0 (the "License");
|
||||||
* you may not use this file except in compliance with the License.
|
* you may not use this file except in compliance with the License.
|
||||||
|
|||||||
@@ -1,5 +1,5 @@
|
|||||||
/*
|
/*
|
||||||
* Copyright 2021-2022 the original author or authors.
|
* Copyright 2021-2023 the original author or authors.
|
||||||
*
|
*
|
||||||
* Licensed under the Apache License, Version 2.0 (the "License");
|
* Licensed under the Apache License, Version 2.0 (the "License");
|
||||||
* you may not use this file except in compliance with the License.
|
* you may not use this file except in compliance with the License.
|
||||||
|
|||||||
@@ -0,0 +1,60 @@
|
|||||||
|
/*
|
||||||
|
* Copyright 2022-2023 the original author or authors.
|
||||||
|
*
|
||||||
|
* Licensed under the Apache License, Version 2.0 (the "License");
|
||||||
|
* you may not use this file except in compliance with the License.
|
||||||
|
* You may obtain a copy of the License at
|
||||||
|
*
|
||||||
|
* https://www.apache.org/licenses/LICENSE-2.0
|
||||||
|
*
|
||||||
|
* Unless required by applicable law or agreed to in writing, software
|
||||||
|
* distributed under the License is distributed on an "AS IS" BASIS,
|
||||||
|
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
||||||
|
* See the License for the specific language governing permissions and
|
||||||
|
* limitations under the License.
|
||||||
|
*/
|
||||||
|
package org.springframework.data.mongodb.core;
|
||||||
|
|
||||||
|
import org.springframework.context.ApplicationEventPublisher;
|
||||||
|
import org.springframework.lang.Nullable;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Delegate class to encapsulate lifecycle event configuration and publishing.
|
||||||
|
*
|
||||||
|
* @author Mark Paluch
|
||||||
|
* @since 4.0
|
||||||
|
* @see ApplicationEventPublisher
|
||||||
|
*/
|
||||||
|
class EntityLifecycleEventDelegate {
|
||||||
|
|
||||||
|
private @Nullable ApplicationEventPublisher publisher;
|
||||||
|
private boolean eventsEnabled = true;
|
||||||
|
|
||||||
|
public void setPublisher(@Nullable ApplicationEventPublisher publisher) {
|
||||||
|
this.publisher = publisher;
|
||||||
|
}
|
||||||
|
|
||||||
|
public boolean isEventsEnabled() {
|
||||||
|
return eventsEnabled;
|
||||||
|
}
|
||||||
|
|
||||||
|
public void setEventsEnabled(boolean eventsEnabled) {
|
||||||
|
this.eventsEnabled = eventsEnabled;
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Publish an application event if event publishing is enabled.
|
||||||
|
*
|
||||||
|
* @param event the application event.
|
||||||
|
*/
|
||||||
|
public void publishEvent(Object event) {
|
||||||
|
|
||||||
|
if (canPublishEvent()) {
|
||||||
|
publisher.publishEvent(event);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
private boolean canPublishEvent() {
|
||||||
|
return publisher != null && eventsEnabled;
|
||||||
|
}
|
||||||
|
}
|
||||||
@@ -1,5 +1,5 @@
|
|||||||
/*
|
/*
|
||||||
* Copyright 2018-2022 the original author or authors.
|
* Copyright 2018-2023 the original author or authors.
|
||||||
*
|
*
|
||||||
* Licensed under the Apache License, Version 2.0 (the "License");
|
* Licensed under the Apache License, Version 2.0 (the "License");
|
||||||
* you may not use this file except in compliance with the License.
|
* you may not use this file except in compliance with the License.
|
||||||
@@ -21,7 +21,6 @@ import java.util.Map;
|
|||||||
import java.util.Optional;
|
import java.util.Optional;
|
||||||
|
|
||||||
import org.bson.Document;
|
import org.bson.Document;
|
||||||
|
|
||||||
import org.springframework.core.convert.ConversionService;
|
import org.springframework.core.convert.ConversionService;
|
||||||
import org.springframework.dao.InvalidDataAccessApiUsageException;
|
import org.springframework.dao.InvalidDataAccessApiUsageException;
|
||||||
import org.springframework.data.convert.CustomConversions;
|
import org.springframework.data.convert.CustomConversions;
|
||||||
@@ -57,6 +56,7 @@ import org.springframework.util.MultiValueMap;
|
|||||||
import org.springframework.util.ObjectUtils;
|
import org.springframework.util.ObjectUtils;
|
||||||
import org.springframework.util.StringUtils;
|
import org.springframework.util.StringUtils;
|
||||||
|
|
||||||
|
import com.mongodb.client.model.ChangeStreamPreAndPostImagesOptions;
|
||||||
import com.mongodb.client.model.CreateCollectionOptions;
|
import com.mongodb.client.model.CreateCollectionOptions;
|
||||||
import com.mongodb.client.model.TimeSeriesGranularity;
|
import com.mongodb.client.model.TimeSeriesGranularity;
|
||||||
import com.mongodb.client.model.ValidationOptions;
|
import com.mongodb.client.model.ValidationOptions;
|
||||||
@@ -174,7 +174,14 @@ class EntityOperations {
|
|||||||
"No class parameter provided, entity collection can't be determined");
|
"No class parameter provided, entity collection can't be determined");
|
||||||
}
|
}
|
||||||
|
|
||||||
return context.getRequiredPersistentEntity(entityClass).getCollection();
|
MongoPersistentEntity<?> persistentEntity = context.getPersistentEntity(entityClass);
|
||||||
|
|
||||||
|
if (persistentEntity == null) {
|
||||||
|
throw new MappingException(String.format(
|
||||||
|
"Cannot determine collection name from type '%s'. Is it a store native type?", entityClass.getName()));
|
||||||
|
}
|
||||||
|
|
||||||
|
return persistentEntity.getCollection();
|
||||||
}
|
}
|
||||||
|
|
||||||
public Query getByIdInQuery(Collection<?> entities) {
|
public Query getByIdInQuery(Collection<?> entities) {
|
||||||
@@ -276,6 +283,10 @@ class EntityOperations {
|
|||||||
* @see EntityProjectionIntrospector#introspect(Class, Class)
|
* @see EntityProjectionIntrospector#introspect(Class, Class)
|
||||||
*/
|
*/
|
||||||
public <M, D> EntityProjection<M, D> introspectProjection(Class<M> resultType, Class<D> entityType) {
|
public <M, D> EntityProjection<M, D> introspectProjection(Class<M> resultType, Class<D> entityType) {
|
||||||
|
|
||||||
|
if (!queryMapper.getMappingContext().hasPersistentEntityFor(entityType)) {
|
||||||
|
return (EntityProjection) EntityProjection.nonProjecting(resultType);
|
||||||
|
}
|
||||||
return introspector.introspect(resultType, entityType);
|
return introspector.introspect(resultType, entityType);
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -334,6 +345,9 @@ class EntityOperations {
|
|||||||
result.timeSeriesOptions(options);
|
result.timeSeriesOptions(options);
|
||||||
});
|
});
|
||||||
|
|
||||||
|
collectionOptions.getChangeStreamOptions().ifPresent(it -> result
|
||||||
|
.changeStreamPreAndPostImagesOptions(new ChangeStreamPreAndPostImagesOptions(it.getPreAndPostImages())));
|
||||||
|
|
||||||
return result;
|
return result;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
@@ -1,5 +1,5 @@
|
|||||||
/*
|
/*
|
||||||
* Copyright 2017-2022 the original author or authors.
|
* Copyright 2017-2023 the original author or authors.
|
||||||
*
|
*
|
||||||
* Licensed under the Apache License, Version 2.0 (the "License");
|
* Licensed under the Apache License, Version 2.0 (the "License");
|
||||||
* you may not use this file except in compliance with the License.
|
* you may not use this file except in compliance with the License.
|
||||||
|
|||||||
@@ -1,5 +1,5 @@
|
|||||||
/*
|
/*
|
||||||
* Copyright 2017-2022 the original author or authors.
|
* Copyright 2017-2023 the original author or authors.
|
||||||
*
|
*
|
||||||
* Licensed under the Apache License, Version 2.0 (the "License");
|
* Licensed under the Apache License, Version 2.0 (the "License");
|
||||||
* you may not use this file except in compliance with the License.
|
* you may not use this file except in compliance with the License.
|
||||||
|
|||||||
@@ -1,5 +1,5 @@
|
|||||||
/*
|
/*
|
||||||
* Copyright 2017-2022 the original author or authors.
|
* Copyright 2017-2023 the original author or authors.
|
||||||
*
|
*
|
||||||
* Licensed under the Apache License, Version 2.0 (the "License");
|
* Licensed under the Apache License, Version 2.0 (the "License");
|
||||||
* you may not use this file except in compliance with the License.
|
* you may not use this file except in compliance with the License.
|
||||||
|
|||||||
@@ -1,5 +1,5 @@
|
|||||||
/*
|
/*
|
||||||
* Copyright 2017-2022 the original author or authors.
|
* Copyright 2017-2023 the original author or authors.
|
||||||
*
|
*
|
||||||
* Licensed under the Apache License, Version 2.0 (the "License");
|
* Licensed under the Apache License, Version 2.0 (the "License");
|
||||||
* you may not use this file except in compliance with the License.
|
* you may not use this file except in compliance with the License.
|
||||||
@@ -20,7 +20,6 @@ import java.util.Optional;
|
|||||||
import java.util.stream.Stream;
|
import java.util.stream.Stream;
|
||||||
|
|
||||||
import org.bson.Document;
|
import org.bson.Document;
|
||||||
|
|
||||||
import org.springframework.dao.IncorrectResultSizeDataAccessException;
|
import org.springframework.dao.IncorrectResultSizeDataAccessException;
|
||||||
import org.springframework.data.mongodb.core.query.NearQuery;
|
import org.springframework.data.mongodb.core.query.NearQuery;
|
||||||
import org.springframework.data.mongodb.core.query.Query;
|
import org.springframework.data.mongodb.core.query.Query;
|
||||||
@@ -168,7 +167,8 @@ class ExecutableFindOperationSupport implements ExecutableFindOperation {
|
|||||||
Document queryObject = query.getQueryObject();
|
Document queryObject = query.getQueryObject();
|
||||||
Document fieldsObject = query.getFieldsObject();
|
Document fieldsObject = query.getFieldsObject();
|
||||||
|
|
||||||
return template.doFind(getCollectionName(), queryObject, fieldsObject, domainType, returnType,
|
return template.doFind(template.createDelegate(query), getCollectionName(), queryObject, fieldsObject, domainType,
|
||||||
|
returnType,
|
||||||
getCursorPreparer(query, preparer));
|
getCursorPreparer(query, preparer));
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
@@ -1,5 +1,5 @@
|
|||||||
/*
|
/*
|
||||||
* Copyright 2017-2022 the original author or authors.
|
* Copyright 2017-2023 the original author or authors.
|
||||||
*
|
*
|
||||||
* Licensed under the Apache License, Version 2.0 (the "License");
|
* Licensed under the Apache License, Version 2.0 (the "License");
|
||||||
* you may not use this file except in compliance with the License.
|
* you may not use this file except in compliance with the License.
|
||||||
|
|||||||
@@ -1,5 +1,5 @@
|
|||||||
/*
|
/*
|
||||||
* Copyright 2017-2022 the original author or authors.
|
* Copyright 2017-2023 the original author or authors.
|
||||||
*
|
*
|
||||||
* Licensed under the Apache License, Version 2.0 (the "License");
|
* Licensed under the Apache License, Version 2.0 (the "License");
|
||||||
* you may not use this file except in compliance with the License.
|
* you may not use this file except in compliance with the License.
|
||||||
|
|||||||
@@ -1,5 +1,5 @@
|
|||||||
/*
|
/*
|
||||||
* Copyright 2018-2022 the original author or authors.
|
* Copyright 2018-2023 the original author or authors.
|
||||||
*
|
*
|
||||||
* Licensed under the Apache License, Version 2.0 (the "License");
|
* Licensed under the Apache License, Version 2.0 (the "License");
|
||||||
* you may not use this file except in compliance with the License.
|
* you may not use this file except in compliance with the License.
|
||||||
@@ -187,7 +187,9 @@ public interface ExecutableMapReduceOperation {
|
|||||||
*
|
*
|
||||||
* @author Christoph Strobl
|
* @author Christoph Strobl
|
||||||
* @since 2.1
|
* @since 2.1
|
||||||
|
* @deprecated since 4.0 in favor of {@link org.springframework.data.mongodb.core.aggregation}.
|
||||||
*/
|
*/
|
||||||
|
@Deprecated
|
||||||
interface MapReduceWithOptions<T> {
|
interface MapReduceWithOptions<T> {
|
||||||
|
|
||||||
/**
|
/**
|
||||||
|
|||||||
Some files were not shown because too many files have changed in this diff Show More
Reference in New Issue
Block a user