Compare commits
272 Commits
| Author | SHA1 | Date | |
|---|---|---|---|
|
|
56972d63b6 | ||
|
|
4dabfd790a | ||
|
|
4bca0ca015 | ||
|
|
80d63a576c | ||
|
|
0f6ee3ddbc | ||
|
|
c3a5f325d2 | ||
|
|
957397eff9 | ||
|
|
f322d5b18f | ||
|
|
24e423b8d1 | ||
|
|
4d5f3c66d5 | ||
|
|
f29d03f9c8 | ||
|
|
fbf4726e56 | ||
|
|
85382f0dd8 | ||
|
|
739b44f6e5 | ||
|
|
49cd518647 | ||
|
|
b59c7f774f | ||
|
|
b7ac5f7970 | ||
|
|
9af1689fbf | ||
|
|
51ca3be48f | ||
|
|
8f8e9c6585 | ||
|
|
092217e425 | ||
|
|
9d1e1b8c17 | ||
|
|
5cf73168f7 | ||
|
|
792d7199f0 | ||
|
|
34a2d09303 | ||
|
|
26554e3031 | ||
|
|
018fe623c0 | ||
|
|
27e6b5a9be | ||
|
|
c9be849e62 | ||
|
|
da5f24981c | ||
|
|
7c7b05f10d | ||
|
|
ed4f30ab07 | ||
|
|
cf38ba15bf | ||
|
|
daf12a6e2b | ||
|
|
d0481d089e | ||
|
|
169c35789d | ||
|
|
0de55deb03 | ||
|
|
01ac35fa31 | ||
|
|
f5c0318a14 | ||
|
|
7a0debe335 | ||
|
|
0a79ad6585 | ||
|
|
404ce6a987 | ||
|
|
232a9c9943 | ||
|
|
7c5ac764b3 | ||
|
|
864c94f490 | ||
|
|
ebc4678aa3 | ||
|
|
28d6e67686 | ||
|
|
ca229cdb99 | ||
|
|
611100e6f4 | ||
|
|
3a6d6bbfed | ||
|
|
286ff1c4a1 | ||
|
|
5df195db15 | ||
|
|
e437865707 | ||
|
|
13888ab7cd | ||
|
|
ced6a1b190 | ||
|
|
e704f147ad | ||
|
|
67ea27d9e4 | ||
|
|
a9ed00530f | ||
|
|
75f73756c9 | ||
|
|
4b137cfd55 | ||
|
|
762aa62b2a | ||
|
|
8f4a8dcbee | ||
|
|
0aa92031a3 | ||
|
|
8aa52c129c | ||
|
|
03ac725080 | ||
|
|
5258b36080 | ||
|
|
ddbec07643 | ||
|
|
f4375fc54d | ||
|
|
ccbd18ff6a | ||
|
|
490ef81d7b | ||
|
|
92668635b1 | ||
|
|
92a07fd024 | ||
|
|
7ebc7d08ed | ||
|
|
1fabfe0385 | ||
|
|
1849afd78b | ||
|
|
8f38113906 | ||
|
|
39593a0388 | ||
|
|
36e639fa51 | ||
|
|
087bef0f0a | ||
|
|
899fb5ee0c | ||
|
|
68530f0e45 | ||
|
|
742cc9e983 | ||
|
|
c9657c3aa4 | ||
|
|
d340125ed5 | ||
|
|
5a702b1624 | ||
|
|
4b92ecc337 | ||
|
|
78899c757f | ||
|
|
a3861b607a | ||
|
|
ee4160997b | ||
|
|
aeeac56d19 | ||
|
|
e9c15eb169 | ||
|
|
7f223d1332 | ||
|
|
cffee123dc | ||
|
|
352376166a | ||
|
|
64b0096c7b | ||
|
|
fb905761a0 | ||
|
|
1e40448b70 | ||
|
|
530912d07f | ||
|
|
82331451ea | ||
|
|
6899567c01 | ||
|
|
0d869b3c23 | ||
|
|
d8ef0db1a9 | ||
|
|
b28da2eed3 | ||
|
|
02de914993 | ||
|
|
5b498f809e | ||
|
|
f94a7ee742 | ||
|
|
ab0ffab488 | ||
|
|
85b47d66f1 | ||
|
|
0d8fe46f3b | ||
|
|
0bc78f99dd | ||
|
|
e4f450f667 | ||
|
|
49cd44295c | ||
|
|
767d97a831 | ||
|
|
bbe8410979 | ||
|
|
c0a4bdb548 | ||
|
|
673a81af0e | ||
|
|
977032620e | ||
|
|
c7263e5b11 | ||
|
|
eed9b2470a | ||
|
|
c350be1f52 | ||
|
|
65b058ffd9 | ||
|
|
4a5789d67e | ||
|
|
7b05cfad94 | ||
|
|
a16a9fe1fe | ||
|
|
2f98a6656b | ||
|
|
9e2f6055a3 | ||
|
|
7f58538292 | ||
|
|
2f208d712c | ||
|
|
63d9875576 | ||
|
|
b7ffff4769 | ||
|
|
715ae26f3c | ||
|
|
00350edd32 | ||
|
|
38e1d0d92d | ||
|
|
8f00ffd291 | ||
|
|
0af8d6839e | ||
|
|
9b02897db5 | ||
|
|
99203b397a | ||
|
|
eda1c79315 | ||
|
|
e7150f525e | ||
|
|
7d6b5ae5fe | ||
|
|
d70e459ffe | ||
|
|
a26e780957 | ||
|
|
8fb0e1326b | ||
|
|
9014f770d8 | ||
|
|
f128e6df15 | ||
|
|
270456ed81 | ||
|
|
4e960a9682 | ||
|
|
061c28f84a | ||
|
|
cba7eaba4c | ||
|
|
ada7e199a4 | ||
|
|
977e5e4c5c | ||
|
|
c8307d5a39 | ||
|
|
dcf184888e | ||
|
|
59d0042d13 | ||
|
|
8af904b81f | ||
|
|
ffceed8da9 | ||
|
|
34d66a276a | ||
|
|
e71ec874ab | ||
|
|
f24e8e5361 | ||
|
|
bf86f39b2d | ||
|
|
f662d7ca0d | ||
|
|
62eb719b1e | ||
|
|
69b582823a | ||
|
|
297ef98239 | ||
|
|
f71f107445 | ||
|
|
36e2d80d71 | ||
|
|
467536cb34 | ||
|
|
302c8031f9 | ||
|
|
7c6e951c7c | ||
|
|
92cc2a582a | ||
|
|
24171b3ae2 | ||
|
|
456c1ad26a | ||
|
|
fc41793d5d | ||
|
|
afef243634 | ||
|
|
869b88702d | ||
|
|
aca403c112 | ||
|
|
df0372eee1 | ||
|
|
c4c6267d91 | ||
|
|
73d5886aae | ||
|
|
0db47169cf | ||
|
|
ec16b873b7 | ||
|
|
2a3a4cf030 | ||
|
|
df2b2a2f68 | ||
|
|
fd0a402c99 | ||
|
|
6bd0f758fe | ||
|
|
10c0203605 | ||
|
|
82b33331fc | ||
|
|
75b5a548b6 | ||
|
|
0c481feb72 | ||
|
|
c8a791d367 | ||
|
|
510028a834 | ||
|
|
1a86761e2e | ||
|
|
30da62181f | ||
|
|
a977b8a790 | ||
|
|
f3e067f59f | ||
|
|
dbfd4e5c62 | ||
|
|
c574e5cf8a | ||
|
|
f9f4c4621b | ||
|
|
23254c10dc | ||
|
|
255491c446 | ||
|
|
1d943d62a3 | ||
|
|
7538b1a1a5 | ||
|
|
828c074167 | ||
|
|
87ab1ac48c | ||
|
|
454afd9877 | ||
|
|
45971b212c | ||
|
|
68370c16fb | ||
|
|
d2c9b47366 | ||
|
|
4d7ee0e741 | ||
|
|
e7f3a2436d | ||
|
|
4ef1ff6aff | ||
|
|
b6ad32d7d4 | ||
|
|
e875f9ea33 | ||
|
|
9db9d16cf8 | ||
|
|
f00991dc29 | ||
|
|
bacbd7133e | ||
|
|
f38f6d67ab | ||
|
|
3f27e8e152 | ||
|
|
23177fef0c | ||
|
|
f3b90c2b8a | ||
|
|
d57c5a9529 | ||
|
|
986ea39f90 | ||
|
|
5bd7ff1413 | ||
|
|
93b9f23b07 | ||
|
|
42ab7d2f63 | ||
|
|
a6a2f0bde9 | ||
|
|
7d0b070d1f | ||
|
|
81bc3c599b | ||
|
|
403f0019d5 | ||
|
|
4f65bb0810 | ||
|
|
ef29e69a87 | ||
|
|
5cffb3c07c | ||
|
|
61d3a0bd1f | ||
|
|
82d67c1dbb | ||
|
|
85a30ec915 | ||
|
|
c70c29b2c7 | ||
|
|
2a5ae0da37 | ||
|
|
826015e9c1 | ||
|
|
9dda0a2f93 | ||
|
|
7dfe460433 | ||
|
|
73a0f04933 | ||
|
|
a1c165921d | ||
|
|
3872b379cd | ||
|
|
98fe043b95 | ||
|
|
c217618d9d | ||
|
|
b1020d19ba | ||
|
|
a481636429 | ||
|
|
efa9a2d408 | ||
|
|
149a703ecc | ||
|
|
2b715c54d3 | ||
|
|
ece261aadb | ||
|
|
dae0ac3b4d | ||
|
|
5ab75eb65a | ||
|
|
e96ef8e18f | ||
|
|
82af678cab | ||
|
|
6ed274bd9b | ||
|
|
48ac7e75ba | ||
|
|
a51c96298f | ||
|
|
f1354c4508 | ||
|
|
ff7588f648 | ||
|
|
124036fe36 | ||
|
|
80c5b536df | ||
|
|
2ee33b1444 | ||
|
|
eec6cea507 | ||
|
|
90d03d92d8 | ||
|
|
9a48e32565 | ||
|
|
ede6927b65 | ||
|
|
2edc29f758 | ||
|
|
5bd9bcca75 | ||
|
|
54f75e653b | ||
|
|
7b33f56e33 | ||
|
|
829eed7d6c |
3
.mvn/wrapper/maven-wrapper.properties
vendored
3
.mvn/wrapper/maven-wrapper.properties
vendored
@@ -1 +1,2 @@
|
|||||||
distributionUrl=https://repo.maven.apache.org/maven2/org/apache/maven/apache-maven/3.5.4/apache-maven-3.5.4-bin.zip
|
#Fri Jun 03 09:42:19 CEST 2022
|
||||||
|
distributionUrl=https\://repo.maven.apache.org/maven2/org/apache/maven/apache-maven/3.8.5/apache-maven-3.8.5-bin.zip
|
||||||
|
|||||||
2
CI.adoc
2
CI.adoc
@@ -1,6 +1,6 @@
|
|||||||
= Continuous Integration
|
= Continuous Integration
|
||||||
|
|
||||||
image:https://jenkins.spring.io/buildStatus/icon?job=spring-data-mongodb%2Fmaster&subject=Moore%20(master)[link=https://jenkins.spring.io/view/SpringData/job/spring-data-mongodb/]
|
image:https://jenkins.spring.io/buildStatus/icon?job=spring-data-mongodb%2Fmain&subject=Moore%20(main)[link=https://jenkins.spring.io/view/SpringData/job/spring-data-mongodb/]
|
||||||
image:https://jenkins.spring.io/buildStatus/icon?job=spring-data-mongodb%2F2.1.x&subject=Lovelace%20(2.1.x)[link=https://jenkins.spring.io/view/SpringData/job/spring-data-mongodb/]
|
image:https://jenkins.spring.io/buildStatus/icon?job=spring-data-mongodb%2F2.1.x&subject=Lovelace%20(2.1.x)[link=https://jenkins.spring.io/view/SpringData/job/spring-data-mongodb/]
|
||||||
image:https://jenkins.spring.io/buildStatus/icon?job=spring-data-mongodb%2F1.10.x&subject=Ingalls%20(1.10.x)[link=https://jenkins.spring.io/view/SpringData/job/spring-data-mongodb/]
|
image:https://jenkins.spring.io/buildStatus/icon?job=spring-data-mongodb%2F1.10.x&subject=Ingalls%20(1.10.x)[link=https://jenkins.spring.io/view/SpringData/job/spring-data-mongodb/]
|
||||||
|
|
||||||
|
|||||||
@@ -1,3 +1,3 @@
|
|||||||
= Spring Data contribution guidelines
|
= Spring Data contribution guidelines
|
||||||
|
|
||||||
You find the contribution guidelines for Spring Data projects https://github.com/spring-projects/spring-data-build/blob/master/CONTRIBUTING.adoc[here].
|
You find the contribution guidelines for Spring Data projects https://github.com/spring-projects/spring-data-build/blob/main/CONTRIBUTING.adoc[here].
|
||||||
|
|||||||
200
Jenkinsfile
vendored
200
Jenkinsfile
vendored
@@ -1,9 +1,15 @@
|
|||||||
|
def p = [:]
|
||||||
|
node {
|
||||||
|
checkout scm
|
||||||
|
p = readProperties interpolate: true, file: 'ci/pipeline.properties'
|
||||||
|
}
|
||||||
|
|
||||||
pipeline {
|
pipeline {
|
||||||
agent none
|
agent none
|
||||||
|
|
||||||
triggers {
|
triggers {
|
||||||
pollSCM 'H/10 * * * *'
|
pollSCM 'H/10 * * * *'
|
||||||
upstream(upstreamProjects: "spring-data-commons/2.5.x", threshold: hudson.model.Result.SUCCESS)
|
upstream(upstreamProjects: "spring-data-commons/2.6.x", threshold: hudson.model.Result.SUCCESS)
|
||||||
}
|
}
|
||||||
|
|
||||||
options {
|
options {
|
||||||
@@ -14,49 +20,77 @@ pipeline {
|
|||||||
stages {
|
stages {
|
||||||
stage("Docker images") {
|
stage("Docker images") {
|
||||||
parallel {
|
parallel {
|
||||||
stage('Publish JDK 8 + MongoDB 4.0') {
|
stage('Publish JDK (main) + MongoDB 4.0') {
|
||||||
when {
|
when {
|
||||||
changeset "ci/openjdk8-mongodb-4.0/**"
|
anyOf {
|
||||||
|
changeset "ci/openjdk8-mongodb-4.0/**"
|
||||||
|
changeset "ci/pipeline.properties"
|
||||||
|
}
|
||||||
}
|
}
|
||||||
agent { label 'data' }
|
agent { label 'data' }
|
||||||
options { timeout(time: 30, unit: 'MINUTES') }
|
options { timeout(time: 30, unit: 'MINUTES') }
|
||||||
|
|
||||||
steps {
|
steps {
|
||||||
script {
|
script {
|
||||||
def image = docker.build("springci/spring-data-openjdk8-with-mongodb-4.0.23", "ci/openjdk8-mongodb-4.0/")
|
def image = docker.build("springci/spring-data-with-mongodb-4.0:${p['java.main.tag']}", "--build-arg BASE=${p['docker.java.main.image']} --build-arg MONGODB=${p['docker.mongodb.4.0.version']} ci/openjdk8-mongodb-4.0/")
|
||||||
docker.withRegistry('', 'hub.docker.com-springbuildmaster') {
|
docker.withRegistry(p['docker.registry'], p['docker.credentials']) {
|
||||||
image.push()
|
image.push()
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
stage('Publish JDK 8 + MongoDB 4.4') {
|
stage('Publish JDK (main) + MongoDB 4.4') {
|
||||||
when {
|
when {
|
||||||
changeset "ci/openjdk8-mongodb-4.4/**"
|
anyOf {
|
||||||
|
changeset "ci/openjdk8-mongodb-4.4/**"
|
||||||
|
changeset "ci/pipeline.properties"
|
||||||
|
}
|
||||||
}
|
}
|
||||||
agent { label 'data' }
|
agent { label 'data' }
|
||||||
options { timeout(time: 30, unit: 'MINUTES') }
|
options { timeout(time: 30, unit: 'MINUTES') }
|
||||||
|
|
||||||
steps {
|
steps {
|
||||||
script {
|
script {
|
||||||
def image = docker.build("springci/spring-data-openjdk8-with-mongodb-4.4.4", "ci/openjdk8-mongodb-4.4/")
|
def image = docker.build("springci/spring-data-with-mongodb-4.4:${p['java.main.tag']}", "--build-arg BASE=${p['docker.java.main.image']} --build-arg MONGODB=${p['docker.mongodb.4.4.version']} ci/openjdk8-mongodb-4.4/")
|
||||||
docker.withRegistry('', 'hub.docker.com-springbuildmaster') {
|
docker.withRegistry(p['docker.registry'], p['docker.credentials']) {
|
||||||
image.push()
|
image.push()
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
stage('Publish JDK 15 + MongoDB 4.4') {
|
stage('Publish JDK (main) + MongoDB 5.0') {
|
||||||
when {
|
when {
|
||||||
changeset "ci/openjdk15-mongodb-4.4/**"
|
anyOf {
|
||||||
|
changeset "ci/openjdk8-mongodb-5.0/**"
|
||||||
|
changeset "ci/pipeline.properties"
|
||||||
|
}
|
||||||
}
|
}
|
||||||
agent { label 'data' }
|
agent { label 'data' }
|
||||||
options { timeout(time: 30, unit: 'MINUTES') }
|
options { timeout(time: 30, unit: 'MINUTES') }
|
||||||
|
|
||||||
steps {
|
steps {
|
||||||
script {
|
script {
|
||||||
def image = docker.build("springci/spring-data-openjdk15-with-mongodb-4.4.4", "ci/openjdk15-mongodb-4.4/")
|
def image = docker.build("springci/spring-data-with-mongodb-5.0:${p['java.main.tag']}", "--build-arg BASE=${p['docker.java.main.image']} --build-arg MONGODB=${p['docker.mongodb.5.0.version']} ci/openjdk8-mongodb-5.0/")
|
||||||
docker.withRegistry('', 'hub.docker.com-springbuildmaster') {
|
docker.withRegistry(p['docker.registry'], p['docker.credentials']) {
|
||||||
|
image.push()
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
stage('Publish JDK (LTS) + MongoDB 4.4') {
|
||||||
|
when {
|
||||||
|
anyOf {
|
||||||
|
changeset "ci/openjdk17-mongodb-4.4/**"
|
||||||
|
changeset "ci/pipeline.properties"
|
||||||
|
}
|
||||||
|
}
|
||||||
|
agent { label 'data' }
|
||||||
|
options { timeout(time: 30, unit: 'MINUTES') }
|
||||||
|
|
||||||
|
steps {
|
||||||
|
script {
|
||||||
|
def image = docker.build("springci/spring-data-with-mongodb-4.4:${p['java.lts.tag']}", "--build-arg BASE=${p['docker.java.lts.image']} --build-arg MONGODB=${p['docker.mongodb.4.4.version']} ci/openjdk17-mongodb-4.4/")
|
||||||
|
docker.withRegistry(p['docker.registry'], p['docker.credentials']) {
|
||||||
image.push()
|
image.push()
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@@ -65,10 +99,11 @@ pipeline {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
stage("test: baseline (jdk8)") {
|
stage("test: baseline (main)") {
|
||||||
when {
|
when {
|
||||||
|
beforeAgent(true)
|
||||||
anyOf {
|
anyOf {
|
||||||
branch '3.2.x'
|
branch(pattern: "main|(\\d\\.\\d\\.x)", comparator: "REGEXP")
|
||||||
not { triggeredBy 'UpstreamCause' }
|
not { triggeredBy 'UpstreamCause' }
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@@ -77,19 +112,17 @@ pipeline {
|
|||||||
}
|
}
|
||||||
options { timeout(time: 30, unit: 'MINUTES') }
|
options { timeout(time: 30, unit: 'MINUTES') }
|
||||||
environment {
|
environment {
|
||||||
ARTIFACTORY = credentials('02bd1690-b54f-4c9f-819d-a77cb7a9822c')
|
ARTIFACTORY = credentials("${p['artifactory.credentials']}")
|
||||||
}
|
}
|
||||||
steps {
|
steps {
|
||||||
script {
|
script {
|
||||||
docker.withRegistry('', 'hub.docker.com-springbuildmaster') {
|
docker.image("harbor-repo.vmware.com/dockerhub-proxy-cache/springci/spring-data-with-mongodb-4.0:${p['java.main.tag']}").inside(p['docker.java.inside.basic']) {
|
||||||
docker.image('springci/spring-data-openjdk8-with-mongodb-4.0.23:latest').inside('-v $HOME:/tmp/jenkins-home') {
|
sh 'mkdir -p /tmp/mongodb/db /tmp/mongodb/log'
|
||||||
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 'mongod --setParameter transactionLifetimeLimitSeconds=90 --setParameter maxTransactionLockRequestTimeoutMillis=10000 --dbpath /tmp/mongodb/db --replSet rs0 --fork --logpath /tmp/mongodb/log/mongod.log &'
|
sh 'sleep 10'
|
||||||
sh 'sleep 10'
|
sh 'mongo --eval "rs.initiate({_id: \'rs0\', members:[{_id: 0, host: \'127.0.0.1:27017\'}]});"'
|
||||||
sh 'mongo --eval "rs.initiate({_id: \'rs0\', members:[{_id: 0, host: \'127.0.0.1:27017\'}]});"'
|
sh 'sleep 15'
|
||||||
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'
|
||||||
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'
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@@ -97,79 +130,74 @@ pipeline {
|
|||||||
|
|
||||||
stage("Test other configurations") {
|
stage("Test other configurations") {
|
||||||
when {
|
when {
|
||||||
|
beforeAgent(true)
|
||||||
allOf {
|
allOf {
|
||||||
branch '3.2.x'
|
branch(pattern: "main|(\\d\\.\\d\\.x)", comparator: "REGEXP")
|
||||||
not { triggeredBy 'UpstreamCause' }
|
not { triggeredBy 'UpstreamCause' }
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
parallel {
|
parallel {
|
||||||
stage("test: mongodb 4.0 (jdk8)") {
|
stage("test: mongodb 4.4 (main)") {
|
||||||
agent {
|
agent {
|
||||||
label 'data'
|
label 'data'
|
||||||
}
|
}
|
||||||
options { timeout(time: 30, unit: 'MINUTES') }
|
options { timeout(time: 30, unit: 'MINUTES') }
|
||||||
environment {
|
environment {
|
||||||
ARTIFACTORY = credentials('02bd1690-b54f-4c9f-819d-a77cb7a9822c')
|
ARTIFACTORY = credentials("${p['artifactory.credentials']}")
|
||||||
}
|
}
|
||||||
steps {
|
steps {
|
||||||
script {
|
script {
|
||||||
docker.withRegistry('', 'hub.docker.com-springbuildmaster') {
|
docker.image("harbor-repo.vmware.com/dockerhub-proxy-cache/springci/spring-data-with-mongodb-4.4:${p['java.main.tag']}").inside(p['docker.java.inside.basic']) {
|
||||||
docker.image('springci/spring-data-openjdk8-with-mongodb-4.0.23:latest').inside('-v $HOME:/tmp/jenkins-home') {
|
sh 'mkdir -p /tmp/mongodb/db /tmp/mongodb/log'
|
||||||
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 'mongod --setParameter transactionLifetimeLimitSeconds=90 --setParameter maxTransactionLockRequestTimeoutMillis=10000 --dbpath /tmp/mongodb/db --replSet rs0 --fork --logpath /tmp/mongodb/log/mongod.log &'
|
sh 'sleep 10'
|
||||||
sh 'sleep 10'
|
sh 'mongo --eval "rs.initiate({_id: \'rs0\', members:[{_id: 0, host: \'127.0.0.1:27017\'}]});"'
|
||||||
sh 'mongo --eval "rs.initiate({_id: \'rs0\', members:[{_id: 0, host: \'127.0.0.1:27017\'}]});"'
|
sh 'sleep 15'
|
||||||
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'
|
||||||
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'
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
stage("test: mongodb 4.4 (jdk8)") {
|
stage("test: mongodb 5.0 (main)") {
|
||||||
agent {
|
agent {
|
||||||
label 'data'
|
label 'data'
|
||||||
}
|
}
|
||||||
options { timeout(time: 30, unit: 'MINUTES') }
|
options { timeout(time: 30, unit: 'MINUTES') }
|
||||||
environment {
|
environment {
|
||||||
ARTIFACTORY = credentials('02bd1690-b54f-4c9f-819d-a77cb7a9822c')
|
ARTIFACTORY = credentials("${p['artifactory.credentials']}")
|
||||||
}
|
}
|
||||||
steps {
|
steps {
|
||||||
script {
|
script {
|
||||||
docker.withRegistry('', 'hub.docker.com-springbuildmaster') {
|
docker.image("harbor-repo.vmware.com/dockerhub-proxy-cache/springci/spring-data-with-mongodb-5.0:${p['java.main.tag']}").inside(p['docker.java.inside.basic']) {
|
||||||
docker.image('springci/spring-data-openjdk8-with-mongodb-4.4.4:latest').inside('-v $HOME:/tmp/jenkins-home') {
|
sh 'mkdir -p /tmp/mongodb/db /tmp/mongodb/log'
|
||||||
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 'mongod --setParameter transactionLifetimeLimitSeconds=90 --setParameter maxTransactionLockRequestTimeoutMillis=10000 --dbpath /tmp/mongodb/db --replSet rs0 --fork --logpath /tmp/mongodb/log/mongod.log &'
|
sh 'sleep 10'
|
||||||
sh 'sleep 10'
|
sh 'mongo --eval "rs.initiate({_id: \'rs0\', members:[{_id: 0, host: \'127.0.0.1:27017\'}]});"'
|
||||||
sh 'mongo --eval "rs.initiate({_id: \'rs0\', members:[{_id: 0, host: \'127.0.0.1:27017\'}]});"'
|
sh 'sleep 15'
|
||||||
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'
|
||||||
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'
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
stage("test: baseline (jdk15)") {
|
stage("test: baseline (LTS)") {
|
||||||
agent {
|
agent {
|
||||||
label 'data'
|
label 'data'
|
||||||
}
|
}
|
||||||
options { timeout(time: 30, unit: 'MINUTES') }
|
options { timeout(time: 30, unit: 'MINUTES') }
|
||||||
environment {
|
environment {
|
||||||
ARTIFACTORY = credentials('02bd1690-b54f-4c9f-819d-a77cb7a9822c')
|
ARTIFACTORY = credentials("${p['artifactory.credentials']}")
|
||||||
}
|
}
|
||||||
steps {
|
steps {
|
||||||
script {
|
script {
|
||||||
docker.withRegistry('', 'hub.docker.com-springbuildmaster') {
|
docker.image("harbor-repo.vmware.com/dockerhub-proxy-cache/springci/spring-data-with-mongodb-4.4:${p['java.lts.tag']}").inside(p['docker.java.inside.basic']) {
|
||||||
docker.image('springci/spring-data-openjdk15-with-mongodb-4.4.4:latest').inside('-v $HOME:/tmp/jenkins-home') {
|
sh 'mkdir -p /tmp/mongodb/db /tmp/mongodb/log'
|
||||||
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 'mongod --setParameter transactionLifetimeLimitSeconds=90 --setParameter maxTransactionLockRequestTimeoutMillis=10000 --dbpath /tmp/mongodb/db --replSet rs0 --fork --logpath /tmp/mongodb/log/mongod.log &'
|
sh 'sleep 10'
|
||||||
sh 'sleep 10'
|
sh 'mongo --eval "rs.initiate({_id: \'rs0\', members:[{_id: 0, host: \'127.0.0.1:27017\'}]});"'
|
||||||
sh 'mongo --eval "rs.initiate({_id: \'rs0\', members:[{_id: 0, host: \'127.0.0.1:27017\'}]});"'
|
sh 'sleep 15'
|
||||||
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'
|
||||||
sh 'MAVEN_OPTS="-Duser.name=jenkins -Duser.home=/tmp/jenkins-home" ./mvnw -s settings.xml -Pjava11 clean dependency:list test -Duser.name=jenkins -Dsort -U -B'
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@@ -179,8 +207,9 @@ pipeline {
|
|||||||
|
|
||||||
stage('Release to artifactory') {
|
stage('Release to artifactory') {
|
||||||
when {
|
when {
|
||||||
|
beforeAgent(true)
|
||||||
anyOf {
|
anyOf {
|
||||||
branch '3.2.x'
|
branch(pattern: "main|(\\d\\.\\d\\.x)", comparator: "REGEXP")
|
||||||
not { triggeredBy 'UpstreamCause' }
|
not { triggeredBy 'UpstreamCause' }
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@@ -190,51 +219,20 @@ pipeline {
|
|||||||
options { timeout(time: 20, unit: 'MINUTES') }
|
options { timeout(time: 20, unit: 'MINUTES') }
|
||||||
|
|
||||||
environment {
|
environment {
|
||||||
ARTIFACTORY = credentials('02bd1690-b54f-4c9f-819d-a77cb7a9822c')
|
ARTIFACTORY = credentials("${p['artifactory.credentials']}")
|
||||||
}
|
}
|
||||||
|
|
||||||
steps {
|
steps {
|
||||||
script {
|
script {
|
||||||
docker.withRegistry('', 'hub.docker.com-springbuildmaster') {
|
docker.image(p['docker.java.main.image']).inside(p['docker.java.inside.basic']) {
|
||||||
docker.image('adoptopenjdk/openjdk8:latest').inside('-v $HOME:/tmp/jenkins-home') {
|
sh 'MAVEN_OPTS="-Duser.name=jenkins -Duser.home=/tmp/jenkins-home" ./mvnw -s settings.xml -Pci,artifactory ' +
|
||||||
sh 'MAVEN_OPTS="-Duser.name=jenkins -Duser.home=/tmp/jenkins-home" ./mvnw -s settings.xml -Pci,artifactory ' +
|
'-Dartifactory.server=https://repo.spring.io ' +
|
||||||
'-Dartifactory.server=https://repo.spring.io ' +
|
"-Dartifactory.username=${ARTIFACTORY_USR} " +
|
||||||
"-Dartifactory.username=${ARTIFACTORY_USR} " +
|
"-Dartifactory.password=${ARTIFACTORY_PSW} " +
|
||||||
"-Dartifactory.password=${ARTIFACTORY_PSW} " +
|
"-Dartifactory.staging-repository=libs-snapshot-local " +
|
||||||
"-Dartifactory.staging-repository=libs-snapshot-local " +
|
"-Dartifactory.build-name=spring-data-mongodb " +
|
||||||
"-Dartifactory.build-name=spring-data-mongodb " +
|
"-Dartifactory.build-number=${BUILD_NUMBER} " +
|
||||||
"-Dartifactory.build-number=${BUILD_NUMBER} " +
|
'-Dmaven.test.skip=true clean deploy -U -B'
|
||||||
'-Dmaven.test.skip=true clean deploy -U -B'
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
stage('Publish documentation') {
|
|
||||||
when {
|
|
||||||
branch '3.2.x'
|
|
||||||
}
|
|
||||||
agent {
|
|
||||||
label 'data'
|
|
||||||
}
|
|
||||||
options { timeout(time: 20, unit: 'MINUTES') }
|
|
||||||
|
|
||||||
environment {
|
|
||||||
ARTIFACTORY = credentials('02bd1690-b54f-4c9f-819d-a77cb7a9822c')
|
|
||||||
}
|
|
||||||
|
|
||||||
steps {
|
|
||||||
script {
|
|
||||||
docker.withRegistry('', 'hub.docker.com-springbuildmaster') {
|
|
||||||
docker.image('adoptopenjdk/openjdk8:latest').inside('-v $HOME:/tmp/jenkins-home') {
|
|
||||||
sh 'MAVEN_OPTS="-Duser.name=jenkins -Duser.home=/tmp/jenkins-home" ./mvnw -s settings.xml -Pci,distribute ' +
|
|
||||||
'-Dartifactory.server=https://repo.spring.io ' +
|
|
||||||
"-Dartifactory.username=${ARTIFACTORY_USR} " +
|
|
||||||
"-Dartifactory.password=${ARTIFACTORY_PSW} " +
|
|
||||||
"-Dartifactory.distribution-repository=temp-private-local " +
|
|
||||||
'-Dmaven.test.skip=true clean deploy -U -B'
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
128
README.adoc
128
README.adoc
@@ -1,17 +1,19 @@
|
|||||||
image:https://spring.io/badges/spring-data-mongodb/ga.svg[Spring Data MongoDB,link=https://projects.spring.io/spring-data-mongodb#quick-start] image:https://spring.io/badges/spring-data-mongodb/snapshot.svg[Spring Data MongoDB,link=https://projects.spring.io/spring-data-mongodb#quick-start]
|
image:https://spring.io/badges/spring-data-mongodb/ga.svg[Spring Data MongoDB,link=https://spring.io/projects/spring-data-mongodb#quick-start] image:https://spring.io/badges/spring-data-mongodb/snapshot.svg[Spring Data MongoDB,link=https://spring.io/projects/spring-data-mongodb#quick-start]
|
||||||
|
|
||||||
= Spring Data MongoDB image:https://jenkins.spring.io/buildStatus/icon?job=spring-data-mongodb%2Fmaster&subject=Build[link=https://jenkins.spring.io/view/SpringData/job/spring-data-mongodb/] https://gitter.im/spring-projects/spring-data[image:https://badges.gitter.im/spring-projects/spring-data.svg[Gitter]]
|
= Spring Data MongoDB image:https://jenkins.spring.io/buildStatus/icon?job=spring-data-mongodb%2Fmain&subject=Build[link=https://jenkins.spring.io/view/SpringData/job/spring-data-mongodb/] https://gitter.im/spring-projects/spring-data[image:https://badges.gitter.im/spring-projects/spring-data.svg[Gitter]]
|
||||||
|
|
||||||
The primary goal of the https://projects.spring.io/spring-data[Spring Data] project is to make it easier to build Spring-powered applications that use new data access technologies such as non-relational databases, map-reduce frameworks, and cloud based data services.
|
The primary goal of the https://spring.io/projects/spring-data[Spring Data] project is to make it easier to build Spring-powered applications that use new data access technologies such as non-relational databases, map-reduce frameworks, and cloud based data services.
|
||||||
|
|
||||||
The Spring Data MongoDB project aims to provide a familiar and consistent Spring-based programming model for new datastores while retaining store-specific features and capabilities.
|
The Spring Data MongoDB project aims to provide a familiar and consistent Spring-based programming model for new datastores while retaining store-specific features and capabilities.
|
||||||
The Spring Data MongoDB project provides integration with the MongoDB document database.
|
The Spring Data MongoDB project provides integration with the MongoDB document database.
|
||||||
Key functional areas of Spring Data MongoDB are a POJO centric model for interacting with a MongoDB `+Document+` and easily writing a repository style data access layer.
|
Key functional areas of Spring Data MongoDB are a POJO centric model for interacting with a MongoDB `+Document+` and easily writing a repository style data access layer.
|
||||||
|
|
||||||
|
[[code-of-conduct]]
|
||||||
== Code of Conduct
|
== Code of Conduct
|
||||||
|
|
||||||
This project is governed by the https://github.com/spring-projects/.github/blob/e3cc2ff230d8f1dca06535aa6b5a4a23815861d4/CODE_OF_CONDUCT.md[Spring Code of Conduct]. By participating, you are expected to uphold this code of conduct. Please report unacceptable behavior to spring-code-of-conduct@pivotal.io.
|
This project is governed by the https://github.com/spring-projects/.github/blob/e3cc2ff230d8f1dca06535aa6b5a4a23815861d4/CODE_OF_CONDUCT.md[Spring Code of Conduct]. By participating, you are expected to uphold this code of conduct. Please report unacceptable behavior to spring-code-of-conduct@pivotal.io.
|
||||||
|
|
||||||
|
[[getting-started]]
|
||||||
== Getting Started
|
== Getting Started
|
||||||
|
|
||||||
Here is a quick teaser of an application using Spring Data Repositories in Java:
|
Here is a quick teaser of an application using Spring Data Repositories in Java:
|
||||||
@@ -59,6 +61,7 @@ class ApplicationConfig extends AbstractMongoClientConfiguration {
|
|||||||
}
|
}
|
||||||
----
|
----
|
||||||
|
|
||||||
|
[[maven-configuration]]
|
||||||
=== Maven configuration
|
=== Maven configuration
|
||||||
|
|
||||||
Add the Maven dependency:
|
Add the Maven dependency:
|
||||||
@@ -68,24 +71,25 @@ Add the Maven dependency:
|
|||||||
<dependency>
|
<dependency>
|
||||||
<groupId>org.springframework.data</groupId>
|
<groupId>org.springframework.data</groupId>
|
||||||
<artifactId>spring-data-mongodb</artifactId>
|
<artifactId>spring-data-mongodb</artifactId>
|
||||||
<version>${version}.RELEASE</version>
|
<version>${version}</version>
|
||||||
</dependency>
|
</dependency>
|
||||||
----
|
----
|
||||||
|
|
||||||
If you'd rather like the latest snapshots of the upcoming major version, use our Maven snapshot repository and declare the appropriate dependency version.
|
If you'd rather like the latest snapshots of the upcoming major version, use our Maven snapshot repository
|
||||||
|
and declare the appropriate dependency version.
|
||||||
|
|
||||||
[source,xml]
|
[source,xml]
|
||||||
----
|
----
|
||||||
<dependency>
|
<dependency>
|
||||||
<groupId>org.springframework.data</groupId>
|
<groupId>org.springframework.data</groupId>
|
||||||
<artifactId>spring-data-mongodb</artifactId>
|
<artifactId>spring-data-mongodb</artifactId>
|
||||||
<version>${version}.BUILD-SNAPSHOT</version>
|
<version>${version}-SNAPSHOT</version>
|
||||||
</dependency>
|
</dependency>
|
||||||
|
|
||||||
<repository>
|
<repository>
|
||||||
<id>spring-libs-snapshot</id>
|
<id>spring-snapshot</id>
|
||||||
<name>Spring Snapshot Repository</name>
|
<name>Spring Snapshot Repository</name>
|
||||||
<url>https://repo.spring.io/libs-snapshot</url>
|
<url>https://repo.spring.io/snapshot</url>
|
||||||
</repository>
|
</repository>
|
||||||
----
|
----
|
||||||
|
|
||||||
@@ -98,7 +102,7 @@ Some of the changes affect the initial setup configuration as well as compile/ru
|
|||||||
|
|
||||||
.Changed XML Namespace Elements and Attributes:
|
.Changed XML Namespace Elements and Attributes:
|
||||||
|===
|
|===
|
||||||
Element / Attribute | 2.x | 3.x
|
| Element / Attribute | 2.x | 3.x
|
||||||
|
|
||||||
| `<mongo:mongo-client />`
|
| `<mongo:mongo-client />`
|
||||||
| Used to create a `com.mongodb.MongoClient`
|
| Used to create a `com.mongodb.MongoClient`
|
||||||
@@ -111,12 +115,12 @@ Use `<mongo:client-settings cluster-hosts="..." />` instead
|
|||||||
|
|
||||||
| `<mongo:db-factory writeConcern="..." />`
|
| `<mongo:db-factory writeConcern="..." />`
|
||||||
| NONE, NORMAL, SAFE, FSYNC_SAFE, REPLICAS_SAFE, MAJORITY
|
| NONE, NORMAL, SAFE, FSYNC_SAFE, REPLICAS_SAFE, MAJORITY
|
||||||
| W1, W2, W3, UNAKNOWLEDGED, AKNOWLEDGED, JOURNALED, MAJORITY
|
| W1, W2, W3, UNACKNOWLEDGED, ACKNOWLEDGED, JOURNALED, MAJORITY
|
||||||
|===
|
|===
|
||||||
|
|
||||||
.Removed XML Namespace Elements and Attributes:
|
.Removed XML Namespace Elements and Attributes:
|
||||||
|===
|
|===
|
||||||
Element / Attribute | Replacement in 3.x | Comment
|
| Element / Attribute | Replacement in 3.x | Comment
|
||||||
|
|
||||||
| `<mongo:db-factory mongo-ref="..." />`
|
| `<mongo:db-factory mongo-ref="..." />`
|
||||||
| `<mongo:db-factory mongo-client-ref="..." />`
|
| `<mongo:db-factory mongo-client-ref="..." />`
|
||||||
@@ -133,7 +137,7 @@ Element / Attribute | Replacement in 3.x | Comment
|
|||||||
|
|
||||||
.New XML Namespace Elements and Attributes:
|
.New XML Namespace Elements and Attributes:
|
||||||
|===
|
|===
|
||||||
Element | Comment
|
| Element | Comment
|
||||||
|
|
||||||
| `<mongo:db-factory mongo-client-ref="..." />`
|
| `<mongo:db-factory mongo-client-ref="..." />`
|
||||||
| Replacement for `<mongo:db-factory mongo-ref="..." />`
|
| Replacement for `<mongo:db-factory mongo-ref="..." />`
|
||||||
@@ -153,7 +157,7 @@ Element | Comment
|
|||||||
|
|
||||||
.Java API changes
|
.Java API changes
|
||||||
|===
|
|===
|
||||||
Type | Comment
|
| Type | Comment
|
||||||
|
|
||||||
| `MongoClientFactoryBean`
|
| `MongoClientFactoryBean`
|
||||||
| Creates `com.mongodb.client.MongoClient` instead of `com.mongodb.MongoClient` +
|
| Creates `com.mongodb.client.MongoClient` instead of `com.mongodb.MongoClient` +
|
||||||
@@ -174,7 +178,7 @@ Uses `MongoClientSettings` instead of `MongoClientOptions`.
|
|||||||
|
|
||||||
.Removed Java API:
|
.Removed Java API:
|
||||||
|===
|
|===
|
||||||
2.x | Replacement in 3.x | Comment
|
| 2.x | Replacement in 3.x | Comment
|
||||||
|
|
||||||
| `MongoClientOptionsFactoryBean`
|
| `MongoClientOptionsFactoryBean`
|
||||||
| `MongoClientSettingsFactoryBean`
|
| `MongoClientSettingsFactoryBean`
|
||||||
@@ -226,6 +230,7 @@ static class Config extends AbstractMongoClientConfiguration {
|
|||||||
----
|
----
|
||||||
====
|
====
|
||||||
|
|
||||||
|
[[getting-help]]
|
||||||
== Getting Help
|
== Getting Help
|
||||||
|
|
||||||
Having trouble with Spring Data? We’d love to help!
|
Having trouble with Spring Data? We’d love to help!
|
||||||
@@ -239,6 +244,7 @@ If you are just starting out with Spring, try one of the https://spring.io/guide
|
|||||||
You can also chat with the community on https://gitter.im/spring-projects/spring-data[Gitter].
|
You can also chat with the community on https://gitter.im/spring-projects/spring-data[Gitter].
|
||||||
* Report bugs with Spring Data MongoDB at https://github.com/spring-projects/spring-data-mongodb/issues[github.com/spring-projects/spring-data-mongodb/issues].
|
* Report bugs with Spring Data MongoDB at https://github.com/spring-projects/spring-data-mongodb/issues[github.com/spring-projects/spring-data-mongodb/issues].
|
||||||
|
|
||||||
|
[[reporting-issues]]
|
||||||
== Reporting Issues
|
== Reporting Issues
|
||||||
|
|
||||||
Spring Data uses Github as issue tracking system to record bugs and feature requests.
|
Spring Data uses Github as issue tracking system to record bugs and feature requests.
|
||||||
@@ -249,10 +255,85 @@ If you want to raise an issue, please follow the recommendations below:
|
|||||||
* Please provide as much information as possible with the issue report, we like to know the version of Spring Data that you are using, the JVM version, Stacktrace, etc.
|
* Please provide as much information as possible with the issue report, we like to know the version of Spring Data that you are using, the JVM version, Stacktrace, etc.
|
||||||
* If you need to paste code, or include a stack trace use https://guides.github.com/features/mastering-markdown/[Markdown] code fences +++```+++.
|
* If you need to paste code, or include a stack trace use https://guides.github.com/features/mastering-markdown/[Markdown] code fences +++```+++.
|
||||||
|
|
||||||
|
[[guides]]
|
||||||
|
== Guides
|
||||||
|
|
||||||
|
The https://spring.io/[spring.io] site contains several guides that show how to use Spring Data step-by-step:
|
||||||
|
|
||||||
|
* https://spring.io/guides/gs/accessing-data-mongodb/[Accessing Data with MongoDB] is a very basic guide that shows you how to create a simple application and how to access data using repositories.
|
||||||
|
* https://spring.io/guides/gs/accessing-mongodb-data-rest/[Accessing MongoDB Data with REST] is a guide to creating a REST web service exposing data stored in MongoDB through repositories.
|
||||||
|
|
||||||
|
[[examples]]
|
||||||
|
== Examples
|
||||||
|
|
||||||
|
* https://github.com/spring-projects/spring-data-examples/[Spring Data Examples] contains example projects that explain specific features in more detail.
|
||||||
|
|
||||||
|
[[building-from-source]]
|
||||||
== Building from Source
|
== Building from Source
|
||||||
|
|
||||||
You don’t need to build from source to use Spring Data (binaries in https://repo.spring.io[repo.spring.io]), but if you want to try out the latest and greatest, Spring Data can be easily built with the https://github.com/takari/maven-wrapper[maven wrapper].
|
You do not need to build from source to use Spring Data. Binaries are available in https://repo.spring.io[repo.spring.io].
|
||||||
You also need JDK 1.8.
|
and accessible from Maven using the Maven configuration noted <<maven-configuration,above>>.
|
||||||
|
|
||||||
|
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].
|
||||||
|
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]
|
||||||
|
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 a reactive one.
|
||||||
|
|
||||||
|
However, if you want to try out the latest and greatest, Spring Data can be easily built with the https://github.com/takari/maven-wrapper[maven wrapper]
|
||||||
|
and minimally JDK 8 (https://www.oracle.com/java/technologies/downloads/[JDK downloads]).
|
||||||
|
|
||||||
|
In order to build Spring Data MongoDB, first you will need to https://www.mongodb.com/try/download/community[download]
|
||||||
|
and https://docs.mongodb.com/manual/installation/[install a MongoDB distribution].
|
||||||
|
|
||||||
|
Once you have installed MongoDB, you need to start a MongoDB server. It is convenient to set an environment variable to
|
||||||
|
your MongoDB installation (e.g. `MONGODB_HOME`).
|
||||||
|
|
||||||
|
To run the full test suite a https://docs.mongodb.com/manual/tutorial/deploy-replica-set/[MongoDB Replica Set] is required.
|
||||||
|
|
||||||
|
To run the MongoDB server enter the following command from a command-line:
|
||||||
|
|
||||||
|
[source,bash]
|
||||||
|
----
|
||||||
|
$ $MONGODB_HOME/bin/mongod --dbpath $MONGODB_HOME/runtime/data --ipv6 --port 27017 --replSet rs0
|
||||||
|
...
|
||||||
|
"msg":"Successfully connected to host"
|
||||||
|
----
|
||||||
|
|
||||||
|
Once the MongoDB server starts up, you should see the message (`msg`), "_Successfully connected to host_".
|
||||||
|
|
||||||
|
Notice the `--dbpath` option to the `mongod` command. You can set this to anything you like, but in this case, we set
|
||||||
|
the absolute path to a sub-directory (`runtime/data/`) under the MongoDB installation directory (in `$MONGODB_HOME`).
|
||||||
|
|
||||||
|
You need to initialize the MongoDB replica set only once on the first time the MongoDB server is started.
|
||||||
|
To initialize the replica set, start a mongo client:
|
||||||
|
|
||||||
|
[source,bash]
|
||||||
|
----
|
||||||
|
$ $MONGODB_HOME/bin/mongo
|
||||||
|
MongoDB server version: 5.0.0
|
||||||
|
...
|
||||||
|
----
|
||||||
|
|
||||||
|
Then enter the following command:
|
||||||
|
|
||||||
|
[source,bash]
|
||||||
|
----
|
||||||
|
mongo> rs.initiate({ _id: 'rs0', members: [ { _id: 0, host: '127.0.0.1:27017' } ] })
|
||||||
|
----
|
||||||
|
|
||||||
|
Finally, on UNIX-based system (for example, Linux or Mac OS X) you may need to adjust the `ulimit`.
|
||||||
|
In case you need to, you can adjust the `ulimit` with the following command (32768 is just a recommendation):
|
||||||
|
|
||||||
|
[source,bash]
|
||||||
|
----
|
||||||
|
$ ulimit -n 32768
|
||||||
|
----
|
||||||
|
|
||||||
|
You can use `ulimit -a` again to verify the `ulimit` on "_open files_" was set appropriately.
|
||||||
|
|
||||||
|
Now you are ready to build Spring Data MongoDB. Simply enter the following `mvnw` (Maven Wrapper) command:
|
||||||
|
|
||||||
[source,bash]
|
[source,bash]
|
||||||
----
|
----
|
||||||
@@ -261,7 +342,8 @@ You also need JDK 1.8.
|
|||||||
|
|
||||||
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.5.0 or above].
|
||||||
|
|
||||||
_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._
|
_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._
|
||||||
|
|
||||||
=== Building reference documentation
|
=== Building reference documentation
|
||||||
|
|
||||||
@@ -274,17 +356,7 @@ Building the documentation builds also the project without running tests.
|
|||||||
|
|
||||||
The generated documentation is available from `target/site/reference/html/index.html`.
|
The generated documentation is available from `target/site/reference/html/index.html`.
|
||||||
|
|
||||||
== Guides
|
[[license]]
|
||||||
|
|
||||||
The https://spring.io/[spring.io] site contains several guides that show how to use Spring Data step-by-step:
|
|
||||||
|
|
||||||
* https://spring.io/guides/gs/accessing-data-mongodb/[Accessing Data with MongoDB] is a very basic guide that shows you how to create a simple application and how to access data using repositories.
|
|
||||||
* https://spring.io/guides/gs/accessing-mongodb-data-rest/[Accessing MongoDB Data with REST] is a guide to creating a REST web service exposing data stored in MongoDB through repositories.
|
|
||||||
|
|
||||||
== Examples
|
|
||||||
|
|
||||||
* https://github.com/spring-projects/spring-data-examples/[Spring Data Examples] contains example projects that explain specific features in more detail.
|
|
||||||
|
|
||||||
== License
|
== License
|
||||||
|
|
||||||
Spring Data MongoDB is Open Source software released under the https://www.apache.org/licenses/LICENSE-2.0.html[Apache 2.0 license].
|
Spring Data MongoDB is Open Source software released under the https://www.apache.org/licenses/LICENSE-2.0.html[Apache 2.0 license].
|
||||||
|
|||||||
@@ -1,15 +1,22 @@
|
|||||||
FROM adoptopenjdk/openjdk11:latest
|
ARG BASE
|
||||||
|
FROM ${BASE}
|
||||||
|
# Any ARG statements before FROM are cleared.
|
||||||
|
ARG MONGODB
|
||||||
|
|
||||||
ENV TZ=Etc/UTC
|
ENV TZ=Etc/UTC
|
||||||
ENV DEBIAN_FRONTEND=noninteractive
|
ENV DEBIAN_FRONTEND=noninteractive
|
||||||
|
|
||||||
RUN set -eux; \
|
RUN set -eux; \
|
||||||
apt-get update && apt-get install -y apt-transport-https apt-utils gnupg2 ; \
|
sed -i -e 's/archive.ubuntu.com/mirror.one.com/g' /etc/apt/sources.list && \
|
||||||
apt-key adv --keyserver hkps://keyserver.ubuntu.com:443 --recv 656408E390CFB1F5 ; \
|
sed -i -e 's/security.ubuntu.com/mirror.one.com/g' /etc/apt/sources.list && \
|
||||||
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; \
|
sed -i -e 's/ports.ubuntu.com/mirrors.ocf.berkeley.edu/g' /etc/apt/sources.list && \
|
||||||
echo ${TZ} > /etc/timezone;
|
sed -i -e 's/http/https/g' /etc/apt/sources.list && \
|
||||||
|
apt-get update && apt-get install -y apt-transport-https apt-utils gnupg2 && \
|
||||||
|
apt-key adv --keyserver hkps://keyserver.ubuntu.com:443 --recv 656408E390CFB1F5 && \
|
||||||
|
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=4.4.4 mongodb-org-server=4.4.4 mongodb-org-shell=4.4.4 mongodb-org-mongos=4.4.4 mongodb-org-tools=4.4.4 ; \
|
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/*
|
||||||
|
|||||||
@@ -1,15 +0,0 @@
|
|||||||
FROM adoptopenjdk/openjdk15:latest
|
|
||||||
|
|
||||||
ENV TZ=Etc/UTC
|
|
||||||
ENV DEBIAN_FRONTEND=noninteractive
|
|
||||||
|
|
||||||
RUN set -eux; \
|
|
||||||
apt-get update && apt-get install -y apt-transport-https apt-utils gnupg2 ; \
|
|
||||||
apt-key adv --keyserver hkps://keyserver.ubuntu.com:443 --recv 656408E390CFB1F5 ; \
|
|
||||||
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; \
|
|
||||||
echo ${TZ} > /etc/timezone;
|
|
||||||
|
|
||||||
RUN apt-get update ; \
|
|
||||||
apt-get install -y mongodb-org=4.4.4 mongodb-org-server=4.4.4 mongodb-org-shell=4.4.4 mongodb-org-mongos=4.4.4 mongodb-org-tools=4.4.4 ; \
|
|
||||||
apt-get clean; \
|
|
||||||
rm -rf /var/lib/apt/lists/*;
|
|
||||||
22
ci/openjdk17-mongodb-4.4/Dockerfile
Normal file
22
ci/openjdk17-mongodb-4.4/Dockerfile
Normal file
@@ -0,0 +1,22 @@
|
|||||||
|
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 && \
|
||||||
|
apt-key adv --keyserver hkps://keyserver.ubuntu.com:443 --recv 656408E390CFB1F5 && \
|
||||||
|
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 && \
|
||||||
|
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,15 +1,22 @@
|
|||||||
FROM adoptopenjdk/openjdk8:latest
|
ARG BASE
|
||||||
|
FROM ${BASE}
|
||||||
|
# Any ARG statements before FROM are cleared.
|
||||||
|
ARG MONGODB
|
||||||
|
|
||||||
ENV TZ=Etc/UTC
|
ENV TZ=Etc/UTC
|
||||||
ENV DEBIAN_FRONTEND=noninteractive
|
ENV DEBIAN_FRONTEND=noninteractive
|
||||||
|
|
||||||
RUN RUN set -eux; \
|
RUN set -eux; \
|
||||||
apt-get update && apt-get install -y apt-transport-https apt-utils gnupg2 ; \
|
sed -i -e 's/archive.ubuntu.com/mirror.one.com/g' /etc/apt/sources.list && \
|
||||||
apt-key adv --keyserver hkps://keyserver.ubuntu.com:443 --recv 9DA31620334BD75D9DCB49F368818C72E52529D4 ; \
|
sed -i -e 's/security.ubuntu.com/mirror.one.com/g' /etc/apt/sources.list && \
|
||||||
echo "deb [ arch=amd64 ] https://repo.mongodb.org/apt/ubuntu bionic/mongodb-org/4.0 multiverse" | tee /etc/apt/sources.list.d/mongodb-org-4.0.list; \
|
sed -i -e 's/ports.ubuntu.com/mirrors.ocf.berkeley.edu/g' /etc/apt/sources.list && \
|
||||||
echo ${TZ} > /etc/timezone;
|
sed -i -e 's/http/https/g' /etc/apt/sources.list && \
|
||||||
|
apt-get update && apt-get install -y apt-transport-https apt-utils gnupg2 && \
|
||||||
|
apt-key adv --keyserver hkps://keyserver.ubuntu.com:443 --recv 9DA31620334BD75D9DCB49F368818C72E52529D4 && \
|
||||||
|
echo "deb [ arch=amd64 ] https://repo.mongodb.org/apt/ubuntu bionic/mongodb-org/4.0 multiverse" | tee /etc/apt/sources.list.d/mongodb-org-4.0.list && \
|
||||||
|
echo ${TZ} > /etc/timezone
|
||||||
|
|
||||||
RUN apt-get update ; \
|
RUN apt-get update && \
|
||||||
apt-get install -y mongodb-org=4.0.23 mongodb-org-server=4.0.23 mongodb-org-shell=4.0.23 mongodb-org-mongos=4.0.23 mongodb-org-tools=4.0.23 ; \
|
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/*
|
||||||
|
|||||||
@@ -1,17 +1,24 @@
|
|||||||
FROM adoptopenjdk/openjdk8:latest
|
ARG BASE
|
||||||
|
FROM ${BASE}
|
||||||
|
# Any ARG statements before FROM are cleared.
|
||||||
|
ARG MONGODB
|
||||||
|
|
||||||
ENV TZ=Etc/UTC
|
ENV TZ=Etc/UTC
|
||||||
ENV DEBIAN_FRONTEND=noninteractive
|
ENV DEBIAN_FRONTEND=noninteractive
|
||||||
|
|
||||||
RUN set -eux; \
|
RUN set -eux; \
|
||||||
apt-get update && apt-get install -y apt-transport-https apt-utils gnupg2 ; \
|
sed -i -e 's/archive.ubuntu.com/mirror.one.com/g' /etc/apt/sources.list && \
|
||||||
apt-key adv --keyserver hkps://keyserver.ubuntu.com:443 --recv 656408E390CFB1F5 ; \
|
sed -i -e 's/security.ubuntu.com/mirror.one.com/g' /etc/apt/sources.list && \
|
||||||
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; \
|
sed -i -e 's/ports.ubuntu.com/mirrors.ocf.berkeley.edu/g' /etc/apt/sources.list && \
|
||||||
echo ${TZ} > /etc/timezone;
|
sed -i -e 's/http/https/g' /etc/apt/sources.list && \
|
||||||
|
apt-get update && apt-get install -y apt-transport-https apt-utils gnupg2 && \
|
||||||
|
apt-key adv --keyserver hkps://keyserver.ubuntu.com:443 --recv 656408E390CFB1F5 && \
|
||||||
|
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 && \
|
||||||
ln -T /bin/true /usr/bin/systemctl ; \
|
ln -T /bin/true /usr/bin/systemctl && \
|
||||||
apt-get install -y mongodb-org=4.4.4 mongodb-org-server=4.4.4 mongodb-org-shell=4.4.4 mongodb-org-mongos=4.4.4 mongodb-org-tools=4.4.4 ; \
|
apt-get install -y mongodb-org=${MONGODB} mongodb-org-server=${MONGODB} mongodb-org-shell=${MONGODB} mongodb-org-mongos=${MONGODB} mongodb-org-tools=${MONGODB} && \
|
||||||
rm /usr/bin/systemctl ; \
|
rm /usr/bin/systemctl && \
|
||||||
apt-get clean; \
|
apt-get clean && \
|
||||||
rm -rf /var/lib/apt/lists/*;
|
rm -rf /var/lib/apt/lists/*
|
||||||
|
|||||||
24
ci/openjdk8-mongodb-5.0/Dockerfile
Normal file
24
ci/openjdk8-mongodb-5.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 5.0 release signing key
|
||||||
|
apt-key adv --keyserver hkps://keyserver.ubuntu.com:443 --recv B00A0BD1E2C63C11 && \
|
||||||
|
# Needed when MongoDB creates a 5.0 folder.
|
||||||
|
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
|
||||||
|
|
||||||
|
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/*
|
||||||
29
ci/pipeline.properties
Normal file
29
ci/pipeline.properties
Normal file
@@ -0,0 +1,29 @@
|
|||||||
|
# Java versions
|
||||||
|
java.main.tag=8u345-b01-jdk-focal
|
||||||
|
java.next.tag=11.0.16.1_1-jdk-focal
|
||||||
|
java.lts.tag=17.0.4.1_1-jdk-focal
|
||||||
|
|
||||||
|
# Docker container images - standard
|
||||||
|
docker.java.main.image=harbor-repo.vmware.com/dockerhub-proxy-cache/library/eclipse-temurin:${java.main.tag}
|
||||||
|
docker.java.next.image=harbor-repo.vmware.com/dockerhub-proxy-cache/library/eclipse-temurin:${java.next.tag}
|
||||||
|
docker.java.lts.image=harbor-repo.vmware.com/dockerhub-proxy-cache/library/eclipse-temurin:${java.lts.tag}
|
||||||
|
|
||||||
|
# Supported versions of MongoDB
|
||||||
|
docker.mongodb.4.0.version=4.0.28
|
||||||
|
docker.mongodb.4.4.version=4.4.12
|
||||||
|
docker.mongodb.5.0.version=5.0.6
|
||||||
|
|
||||||
|
# Supported versions of Redis
|
||||||
|
docker.redis.6.version=6.2.6
|
||||||
|
|
||||||
|
# Supported versions of Cassandra
|
||||||
|
docker.cassandra.3.version=3.11.12
|
||||||
|
|
||||||
|
# Docker environment settings
|
||||||
|
docker.java.inside.basic=-v $HOME:/tmp/jenkins-home
|
||||||
|
docker.java.inside.docker=-u root -v /var/run/docker.sock:/var/run/docker.sock -v /usr/bin/docker:/usr/bin/docker -v $HOME:/tmp/jenkins-home
|
||||||
|
|
||||||
|
# Credentials
|
||||||
|
docker.registry=
|
||||||
|
docker.credentials=hub.docker.com-springbuildmaster
|
||||||
|
artifactory.credentials=02bd1690-b54f-4c9f-819d-a77cb7a9822c
|
||||||
33
pom.xml
33
pom.xml
@@ -5,17 +5,17 @@
|
|||||||
|
|
||||||
<groupId>org.springframework.data</groupId>
|
<groupId>org.springframework.data</groupId>
|
||||||
<artifactId>spring-data-mongodb-parent</artifactId>
|
<artifactId>spring-data-mongodb-parent</artifactId>
|
||||||
<version>3.2.2</version>
|
<version>3.3.11-SNAPSHOT</version>
|
||||||
<packaging>pom</packaging>
|
<packaging>pom</packaging>
|
||||||
|
|
||||||
<name>Spring Data MongoDB</name>
|
<name>Spring Data MongoDB</name>
|
||||||
<description>MongoDB support for Spring Data</description>
|
<description>MongoDB support for Spring Data</description>
|
||||||
<url>https://projects.spring.io/spring-data-mongodb</url>
|
<url>https://spring.io/projects/spring-data-mongodb</url>
|
||||||
|
|
||||||
<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>2.5.2</version>
|
<version>2.6.11-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>2.5.2</springdata.commons>
|
<springdata.commons>2.6.11-SNAPSHOT</springdata.commons>
|
||||||
<mongo>4.2.3</mongo>
|
<mongo>4.4.2</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>
|
||||||
@@ -112,6 +112,17 @@
|
|||||||
</developer>
|
</developer>
|
||||||
</developers>
|
</developers>
|
||||||
|
|
||||||
|
<scm>
|
||||||
|
<connection>scm:git:https://github.com/spring-projects/spring-data-mongodb.git</connection>
|
||||||
|
<developerConnection>scm:git:git@github.com:spring-projects/spring-data-mongodb.git</developerConnection>
|
||||||
|
<url>https://github.com/spring-projects/spring-data-mongodb</url>
|
||||||
|
</scm>
|
||||||
|
|
||||||
|
<issueManagement>
|
||||||
|
<system>GitHub</system>
|
||||||
|
<url>https://github.com/spring-projects/spring-data-mongodb/issues</url>
|
||||||
|
</issueManagement>
|
||||||
|
|
||||||
<profiles>
|
<profiles>
|
||||||
<profile>
|
<profile>
|
||||||
<id>benchmarks</id>
|
<id>benchmarks</id>
|
||||||
@@ -134,18 +145,18 @@
|
|||||||
|
|
||||||
<repositories>
|
<repositories>
|
||||||
<repository>
|
<repository>
|
||||||
<id>spring-libs-release</id>
|
<id>spring-libs-snapshot</id>
|
||||||
<url>https://repo.spring.io/libs-release</url>
|
<url>https://repo.spring.io/libs-snapshot</url>
|
||||||
</repository>
|
</repository>
|
||||||
<repository>
|
<repository>
|
||||||
<id>sonatype-libs-snapshot</id>
|
<id>sonatype-libs-snapshot</id>
|
||||||
<url>https://oss.sonatype.org/content/repositories/snapshots</url>
|
<url>https://oss.sonatype.org/content/repositories/snapshots</url>
|
||||||
<releases>
|
<releases>
|
||||||
<enabled>false</enabled>
|
<enabled>false</enabled>
|
||||||
</releases>
|
</releases>
|
||||||
<snapshots>
|
<snapshots>
|
||||||
<enabled>true</enabled>
|
<enabled>true</enabled>
|
||||||
</snapshots>
|
</snapshots>
|
||||||
</repository>
|
</repository>
|
||||||
</repositories>
|
</repositories>
|
||||||
|
|
||||||
|
|||||||
@@ -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>3.2.2</version>
|
<version>3.3.11-SNAPSHOT</version>
|
||||||
<relativePath>../pom.xml</relativePath>
|
<relativePath>../pom.xml</relativePath>
|
||||||
</parent>
|
</parent>
|
||||||
|
|
||||||
|
|||||||
@@ -1,5 +1,5 @@
|
|||||||
/*
|
/*
|
||||||
* Copyright 2017-2021 the original author or authors.
|
* Copyright 2017-2022 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-2021 the original author or authors.
|
* Copyright 2017-2022 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-2021 the original author or authors.
|
* Copyright 2017-2022 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-2021 the original author or authors.
|
* Copyright 2017-2022 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-2021 the original author or authors.
|
* Copyright 2017-2022 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-2021 the original author or authors.
|
* Copyright 2017-2022 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-2021 the original author or authors.
|
* Copyright 2017-2022 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.
|
||||||
|
|||||||
@@ -14,7 +14,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>3.2.2</version>
|
<version>3.3.11-SNAPSHOT</version>
|
||||||
<relativePath>../pom.xml</relativePath>
|
<relativePath>../pom.xml</relativePath>
|
||||||
</parent>
|
</parent>
|
||||||
|
|
||||||
|
|||||||
@@ -11,7 +11,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>3.2.2</version>
|
<version>3.3.11-SNAPSHOT</version>
|
||||||
<relativePath>../pom.xml</relativePath>
|
<relativePath>../pom.xml</relativePath>
|
||||||
</parent>
|
</parent>
|
||||||
|
|
||||||
@@ -87,6 +87,13 @@
|
|||||||
<optional>true</optional>
|
<optional>true</optional>
|
||||||
</dependency>
|
</dependency>
|
||||||
|
|
||||||
|
<dependency>
|
||||||
|
<groupId>com.google.code.findbugs</groupId>
|
||||||
|
<artifactId>jsr305</artifactId>
|
||||||
|
<version>3.0.2</version>
|
||||||
|
<optional>true</optional>
|
||||||
|
</dependency>
|
||||||
|
|
||||||
<!-- reactive -->
|
<!-- reactive -->
|
||||||
|
|
||||||
<dependency>
|
<dependency>
|
||||||
@@ -310,6 +317,15 @@
|
|||||||
<scope>test</scope>
|
<scope>test</scope>
|
||||||
</dependency>
|
</dependency>
|
||||||
|
|
||||||
|
<!-- jMolecules -->
|
||||||
|
|
||||||
|
<dependency>
|
||||||
|
<groupId>org.jmolecules</groupId>
|
||||||
|
<artifactId>jmolecules-ddd</artifactId>
|
||||||
|
<version>${jmolecules}</version>
|
||||||
|
<scope>test</scope>
|
||||||
|
</dependency>
|
||||||
|
|
||||||
</dependencies>
|
</dependencies>
|
||||||
|
|
||||||
<build>
|
<build>
|
||||||
|
|||||||
@@ -1,5 +1,5 @@
|
|||||||
/*
|
/*
|
||||||
* Copyright 2021 the original author or authors.
|
* Copyright 2021-2022 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,7 @@ import org.springframework.util.StringUtils;
|
|||||||
* expression. The expression will be wrapped within <code>{ ... }</code> if necessary. The actual parsing and parameter
|
* expression. The expression will be wrapped within <code>{ ... }</code> if necessary. The actual parsing and parameter
|
||||||
* binding of placeholders like {@code ?0} is delayed upon first call on the the target {@link Document} via
|
* binding of placeholders like {@code ?0} is delayed upon first call on the the target {@link Document} via
|
||||||
* {@link #toDocument()}.
|
* {@link #toDocument()}.
|
||||||
* <p />
|
* <br />
|
||||||
*
|
*
|
||||||
* <pre class="code">
|
* <pre class="code">
|
||||||
* $toUpper : $name -> { '$toUpper' : '$name' }
|
* $toUpper : $name -> { '$toUpper' : '$name' }
|
||||||
|
|||||||
@@ -1,5 +1,5 @@
|
|||||||
/*
|
/*
|
||||||
* Copyright 2015-2021 the original author or authors.
|
* Copyright 2015-2022 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-2021 the original author or authors.
|
* Copyright 2018-2022 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-2021 the original author or authors.
|
* Copyright 2017-2022 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-2021 the original author or authors.
|
* Copyright 2010-2022 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-2021 the original author or authors.
|
* Copyright 2013-2022 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-2021 the original author or authors.
|
* Copyright 2011-2022 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,8 +20,8 @@ import org.springframework.util.StringUtils;
|
|||||||
|
|
||||||
/**
|
/**
|
||||||
* Helper class featuring helper methods for working with MongoDb collections.
|
* Helper class featuring helper methods for working with MongoDb collections.
|
||||||
* <p/>
|
* <br />
|
||||||
* <p/>
|
* <br />
|
||||||
* Mainly intended for internal use within the framework.
|
* Mainly intended for internal use within the framework.
|
||||||
*
|
*
|
||||||
* @author Thomas Risberg
|
* @author Thomas Risberg
|
||||||
|
|||||||
@@ -1,5 +1,5 @@
|
|||||||
/*
|
/*
|
||||||
* Copyright 2011-2021 the original author or authors.
|
* Copyright 2011-2022 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-2021 the original author or authors.
|
* Copyright 2018-2022 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.
|
||||||
@@ -30,7 +30,7 @@ import com.mongodb.client.MongoDatabase;
|
|||||||
* Helper class for managing a {@link MongoDatabase} instances via {@link MongoDatabaseFactory}. Used for obtaining
|
* Helper class for managing a {@link MongoDatabase} instances via {@link MongoDatabaseFactory}. Used for obtaining
|
||||||
* {@link ClientSession session bound} resources, such as {@link MongoDatabase} and
|
* {@link ClientSession session bound} resources, such as {@link MongoDatabase} and
|
||||||
* {@link com.mongodb.client.MongoCollection} suitable for transactional usage.
|
* {@link com.mongodb.client.MongoCollection} suitable for transactional usage.
|
||||||
* <p />
|
* <br />
|
||||||
* <strong>Note:</strong> Intended for internal usage only.
|
* <strong>Note:</strong> Intended for internal usage only.
|
||||||
*
|
*
|
||||||
* @author Christoph Strobl
|
* @author Christoph Strobl
|
||||||
@@ -43,7 +43,7 @@ public class MongoDatabaseUtils {
|
|||||||
/**
|
/**
|
||||||
* Obtain the default {@link MongoDatabase database} form the given {@link MongoDatabaseFactory factory} using
|
* Obtain the default {@link MongoDatabase database} form the given {@link MongoDatabaseFactory factory} using
|
||||||
* {@link SessionSynchronization#ON_ACTUAL_TRANSACTION native session synchronization}.
|
* {@link SessionSynchronization#ON_ACTUAL_TRANSACTION native session synchronization}.
|
||||||
* <p />
|
* <br />
|
||||||
* Registers a {@link MongoSessionSynchronization MongoDB specific transaction synchronization} within the current
|
* Registers a {@link MongoSessionSynchronization MongoDB specific transaction synchronization} within the current
|
||||||
* {@link Thread} if {@link TransactionSynchronizationManager#isSynchronizationActive() synchronization is active}.
|
* {@link Thread} if {@link TransactionSynchronizationManager#isSynchronizationActive() synchronization is active}.
|
||||||
*
|
*
|
||||||
@@ -56,7 +56,7 @@ public class MongoDatabaseUtils {
|
|||||||
|
|
||||||
/**
|
/**
|
||||||
* Obtain the default {@link MongoDatabase database} form the given {@link MongoDatabaseFactory factory}.
|
* Obtain the default {@link MongoDatabase database} form the given {@link MongoDatabaseFactory factory}.
|
||||||
* <p />
|
* <br />
|
||||||
* Registers a {@link MongoSessionSynchronization MongoDB specific transaction synchronization} within the current
|
* Registers a {@link MongoSessionSynchronization MongoDB specific transaction synchronization} within the current
|
||||||
* {@link Thread} if {@link TransactionSynchronizationManager#isSynchronizationActive() synchronization is active}.
|
* {@link Thread} if {@link TransactionSynchronizationManager#isSynchronizationActive() synchronization is active}.
|
||||||
*
|
*
|
||||||
@@ -71,7 +71,7 @@ public class MongoDatabaseUtils {
|
|||||||
/**
|
/**
|
||||||
* Obtain the {@link MongoDatabase database} with given name form the given {@link MongoDatabaseFactory factory} using
|
* Obtain the {@link MongoDatabase database} with given name form the given {@link MongoDatabaseFactory factory} using
|
||||||
* {@link SessionSynchronization#ON_ACTUAL_TRANSACTION native session synchronization}.
|
* {@link SessionSynchronization#ON_ACTUAL_TRANSACTION native session synchronization}.
|
||||||
* <p />
|
* <br />
|
||||||
* Registers a {@link MongoSessionSynchronization MongoDB specific transaction synchronization} within the current
|
* Registers a {@link MongoSessionSynchronization MongoDB specific transaction synchronization} within the current
|
||||||
* {@link Thread} if {@link TransactionSynchronizationManager#isSynchronizationActive() synchronization is active}.
|
* {@link Thread} if {@link TransactionSynchronizationManager#isSynchronizationActive() synchronization is active}.
|
||||||
*
|
*
|
||||||
@@ -85,7 +85,7 @@ public class MongoDatabaseUtils {
|
|||||||
|
|
||||||
/**
|
/**
|
||||||
* Obtain the {@link MongoDatabase database} with given name form the given {@link MongoDatabaseFactory factory}.
|
* Obtain the {@link MongoDatabase database} with given name form the given {@link MongoDatabaseFactory factory}.
|
||||||
* <p />
|
* <br />
|
||||||
* Registers a {@link MongoSessionSynchronization MongoDB specific transaction synchronization} within the current
|
* Registers a {@link MongoSessionSynchronization MongoDB specific transaction synchronization} within the current
|
||||||
* {@link Thread} if {@link TransactionSynchronizationManager#isSynchronizationActive() synchronization is active}.
|
* {@link Thread} if {@link TransactionSynchronizationManager#isSynchronizationActive() synchronization is active}.
|
||||||
*
|
*
|
||||||
@@ -104,7 +104,8 @@ public class MongoDatabaseUtils {
|
|||||||
|
|
||||||
Assert.notNull(factory, "Factory must not be null!");
|
Assert.notNull(factory, "Factory must not be null!");
|
||||||
|
|
||||||
if (!TransactionSynchronizationManager.isSynchronizationActive()) {
|
if (sessionSynchronization == SessionSynchronization.NEVER
|
||||||
|
|| !TransactionSynchronizationManager.isSynchronizationActive()) {
|
||||||
return StringUtils.hasText(dbName) ? factory.getMongoDatabase(dbName) : factory.getMongoDatabase();
|
return StringUtils.hasText(dbName) ? factory.getMongoDatabase(dbName) : factory.getMongoDatabase();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
@@ -1,5 +1,5 @@
|
|||||||
/*
|
/*
|
||||||
* Copyright 2011-2021 the original author or authors.
|
* Copyright 2011-2022 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 the original author or authors.
|
* Copyright 2021-2022 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.
|
||||||
@@ -18,7 +18,7 @@ package org.springframework.data.mongodb;
|
|||||||
/**
|
/**
|
||||||
* Wrapper object for MongoDB expressions like {@code $toUpper : $name} that manifest as {@link org.bson.Document} when
|
* Wrapper object for MongoDB expressions like {@code $toUpper : $name} that manifest as {@link org.bson.Document} when
|
||||||
* passed on to the driver.
|
* passed on to the driver.
|
||||||
* <p />
|
* <br />
|
||||||
* A set of predefined {@link MongoExpression expressions}, including a
|
* A set of predefined {@link MongoExpression expressions}, including a
|
||||||
* {@link org.springframework.data.mongodb.core.aggregation.AggregationSpELExpression SpEL based variant} for method
|
* {@link org.springframework.data.mongodb.core.aggregation.AggregationSpELExpression SpEL based variant} for method
|
||||||
* like expressions (eg. {@code toUpper(name)}) are available via the
|
* like expressions (eg. {@code toUpper(name)}) are available via the
|
||||||
|
|||||||
@@ -1,5 +1,5 @@
|
|||||||
/*
|
/*
|
||||||
* Copyright 2018-2021 the original author or authors.
|
* Copyright 2018-2022 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,7 +24,7 @@ import com.mongodb.client.ClientSession;
|
|||||||
/**
|
/**
|
||||||
* MongoDB specific {@link ResourceHolderSupport resource holder}, wrapping a {@link ClientSession}.
|
* MongoDB specific {@link ResourceHolderSupport resource holder}, wrapping a {@link ClientSession}.
|
||||||
* {@link MongoTransactionManager} binds instances of this class to the thread.
|
* {@link MongoTransactionManager} binds instances of this class to the thread.
|
||||||
* <p />
|
* <br />
|
||||||
* <strong>Note:</strong> Intended for internal usage only.
|
* <strong>Note:</strong> Intended for internal usage only.
|
||||||
*
|
*
|
||||||
* @author Christoph Strobl
|
* @author Christoph Strobl
|
||||||
|
|||||||
@@ -1,5 +1,5 @@
|
|||||||
/*
|
/*
|
||||||
* Copyright 2018-2021 the original author or authors.
|
* Copyright 2018-2022 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-2021 the original author or authors.
|
* Copyright 2018-2022 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-2021 the original author or authors.
|
* Copyright 2018-2022 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.
|
||||||
@@ -37,18 +37,18 @@ import com.mongodb.client.ClientSession;
|
|||||||
/**
|
/**
|
||||||
* A {@link org.springframework.transaction.PlatformTransactionManager} implementation that manages
|
* A {@link org.springframework.transaction.PlatformTransactionManager} implementation that manages
|
||||||
* {@link ClientSession} based transactions for a single {@link MongoDatabaseFactory}.
|
* {@link ClientSession} based transactions for a single {@link MongoDatabaseFactory}.
|
||||||
* <p />
|
* <br />
|
||||||
* Binds a {@link ClientSession} from the specified {@link MongoDatabaseFactory} to the thread.
|
* Binds a {@link ClientSession} from the specified {@link MongoDatabaseFactory} to the thread.
|
||||||
* <p />
|
* <br />
|
||||||
* {@link TransactionDefinition#isReadOnly() Readonly} transactions operate on a {@link ClientSession} and enable causal
|
* {@link TransactionDefinition#isReadOnly() Readonly} transactions operate on a {@link ClientSession} and enable causal
|
||||||
* consistency, and also {@link ClientSession#startTransaction() start}, {@link ClientSession#commitTransaction()
|
* consistency, and also {@link ClientSession#startTransaction() start}, {@link ClientSession#commitTransaction()
|
||||||
* commit} or {@link ClientSession#abortTransaction() abort} a transaction.
|
* commit} or {@link ClientSession#abortTransaction() abort} a transaction.
|
||||||
* <p />
|
* <br />
|
||||||
* Application code is required to retrieve the {@link com.mongodb.client.MongoDatabase} via
|
* Application code is required to retrieve the {@link com.mongodb.client.MongoDatabase} via
|
||||||
* {@link MongoDatabaseUtils#getDatabase(MongoDatabaseFactory)} instead of a standard
|
* {@link MongoDatabaseUtils#getDatabase(MongoDatabaseFactory)} instead of a standard
|
||||||
* {@link MongoDatabaseFactory#getMongoDatabase()} call. Spring classes such as
|
* {@link MongoDatabaseFactory#getMongoDatabase()} call. Spring classes such as
|
||||||
* {@link org.springframework.data.mongodb.core.MongoTemplate} use this strategy implicitly.
|
* {@link org.springframework.data.mongodb.core.MongoTemplate} use this strategy implicitly.
|
||||||
* <p />
|
* <br />
|
||||||
* By default failure of a {@literal commit} operation raises a {@link TransactionSystemException}. One may override
|
* By default failure of a {@literal commit} operation raises a {@link TransactionSystemException}. One may override
|
||||||
* {@link #doCommit(MongoTransactionObject)} to implement the
|
* {@link #doCommit(MongoTransactionObject)} to implement the
|
||||||
* <a href="https://docs.mongodb.com/manual/core/transactions/#retry-commit-operation">Retry Commit Operation</a>
|
* <a href="https://docs.mongodb.com/manual/core/transactions/#retry-commit-operation">Retry Commit Operation</a>
|
||||||
@@ -69,11 +69,11 @@ public class MongoTransactionManager extends AbstractPlatformTransactionManager
|
|||||||
|
|
||||||
/**
|
/**
|
||||||
* Create a new {@link MongoTransactionManager} for bean-style usage.
|
* Create a new {@link MongoTransactionManager} for bean-style usage.
|
||||||
* <p />
|
* <br />
|
||||||
* <strong>Note:</strong>The {@link MongoDatabaseFactory db factory} has to be
|
* <strong>Note:</strong>The {@link MongoDatabaseFactory db factory} has to be
|
||||||
* {@link #setDbFactory(MongoDatabaseFactory) set} before using the instance. Use this constructor to prepare a
|
* {@link #setDbFactory(MongoDatabaseFactory) set} before using the instance. Use this constructor to prepare a
|
||||||
* {@link MongoTransactionManager} via a {@link org.springframework.beans.factory.BeanFactory}.
|
* {@link MongoTransactionManager} via a {@link org.springframework.beans.factory.BeanFactory}.
|
||||||
* <p />
|
* <br />
|
||||||
* Optionally it is possible to set default {@link TransactionOptions transaction options} defining
|
* Optionally it is possible to set default {@link TransactionOptions transaction options} defining
|
||||||
* {@link com.mongodb.ReadConcern} and {@link com.mongodb.WriteConcern}.
|
* {@link com.mongodb.ReadConcern} and {@link com.mongodb.WriteConcern}.
|
||||||
*
|
*
|
||||||
@@ -212,8 +212,8 @@ public class MongoTransactionManager extends AbstractPlatformTransactionManager
|
|||||||
* By default those labels are ignored, nevertheless one might check for
|
* By default those labels are ignored, nevertheless one might check for
|
||||||
* {@link MongoException#UNKNOWN_TRANSACTION_COMMIT_RESULT_LABEL transient commit errors labels} and retry the the
|
* {@link MongoException#UNKNOWN_TRANSACTION_COMMIT_RESULT_LABEL transient commit errors labels} and retry the the
|
||||||
* commit. <br />
|
* commit. <br />
|
||||||
|
* <pre>
|
||||||
* <code>
|
* <code>
|
||||||
* <pre>
|
|
||||||
* int retries = 3;
|
* int retries = 3;
|
||||||
* do {
|
* do {
|
||||||
* try {
|
* try {
|
||||||
@@ -226,8 +226,8 @@ public class MongoTransactionManager extends AbstractPlatformTransactionManager
|
|||||||
* }
|
* }
|
||||||
* Thread.sleep(500);
|
* Thread.sleep(500);
|
||||||
* } while (--retries > 0);
|
* } while (--retries > 0);
|
||||||
* </pre>
|
|
||||||
* </code>
|
* </code>
|
||||||
|
* </pre>
|
||||||
*
|
*
|
||||||
* @param transactionObject never {@literal null}.
|
* @param transactionObject never {@literal null}.
|
||||||
* @throws Exception in case of transaction errors.
|
* @throws Exception in case of transaction errors.
|
||||||
|
|||||||
@@ -1,5 +1,5 @@
|
|||||||
/*
|
/*
|
||||||
* Copyright 2016-2021 the original author or authors.
|
* Copyright 2016-2022 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-2021 the original author or authors.
|
* Copyright 2019-2022 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,7 +36,7 @@ import com.mongodb.reactivestreams.client.MongoDatabase;
|
|||||||
* Helper class for managing reactive {@link MongoDatabase} instances via {@link ReactiveMongoDatabaseFactory}. Used for
|
* Helper class for managing reactive {@link MongoDatabase} instances via {@link ReactiveMongoDatabaseFactory}. Used for
|
||||||
* obtaining {@link ClientSession session bound} resources, such as {@link MongoDatabase} and {@link MongoCollection}
|
* obtaining {@link ClientSession session bound} resources, such as {@link MongoDatabase} and {@link MongoCollection}
|
||||||
* suitable for transactional usage.
|
* suitable for transactional usage.
|
||||||
* <p />
|
* <br />
|
||||||
* <strong>Note:</strong> Intended for internal usage only.
|
* <strong>Note:</strong> Intended for internal usage only.
|
||||||
*
|
*
|
||||||
* @author Mark Paluch
|
* @author Mark Paluch
|
||||||
@@ -75,7 +75,7 @@ public class ReactiveMongoDatabaseUtils {
|
|||||||
/**
|
/**
|
||||||
* Obtain the default {@link MongoDatabase database} form the given {@link ReactiveMongoDatabaseFactory factory} using
|
* Obtain the default {@link MongoDatabase database} form the given {@link ReactiveMongoDatabaseFactory factory} using
|
||||||
* {@link SessionSynchronization#ON_ACTUAL_TRANSACTION native session synchronization}.
|
* {@link SessionSynchronization#ON_ACTUAL_TRANSACTION native session synchronization}.
|
||||||
* <p />
|
* <br />
|
||||||
* Registers a {@link MongoSessionSynchronization MongoDB specific transaction synchronization} within the subscriber
|
* Registers a {@link MongoSessionSynchronization MongoDB specific transaction synchronization} within the subscriber
|
||||||
* {@link Context} if {@link TransactionSynchronizationManager#isSynchronizationActive() synchronization is active}.
|
* {@link Context} if {@link TransactionSynchronizationManager#isSynchronizationActive() synchronization is active}.
|
||||||
*
|
*
|
||||||
@@ -88,7 +88,7 @@ public class ReactiveMongoDatabaseUtils {
|
|||||||
|
|
||||||
/**
|
/**
|
||||||
* Obtain the default {@link MongoDatabase database} form the given {@link ReactiveMongoDatabaseFactory factory}.
|
* Obtain the default {@link MongoDatabase database} form the given {@link ReactiveMongoDatabaseFactory factory}.
|
||||||
* <p />
|
* <br />
|
||||||
* Registers a {@link MongoSessionSynchronization MongoDB specific transaction synchronization} within the subscriber
|
* Registers a {@link MongoSessionSynchronization MongoDB specific transaction synchronization} within the subscriber
|
||||||
* {@link Context} if {@link TransactionSynchronizationManager#isSynchronizationActive() synchronization is active}.
|
* {@link Context} if {@link TransactionSynchronizationManager#isSynchronizationActive() synchronization is active}.
|
||||||
*
|
*
|
||||||
@@ -104,7 +104,7 @@ public class ReactiveMongoDatabaseUtils {
|
|||||||
/**
|
/**
|
||||||
* Obtain the {@link MongoDatabase database} with given name form the given {@link ReactiveMongoDatabaseFactory
|
* Obtain the {@link MongoDatabase database} with given name form the given {@link ReactiveMongoDatabaseFactory
|
||||||
* factory} using {@link SessionSynchronization#ON_ACTUAL_TRANSACTION native session synchronization}.
|
* factory} using {@link SessionSynchronization#ON_ACTUAL_TRANSACTION native session synchronization}.
|
||||||
* <p />
|
* <br />
|
||||||
* Registers a {@link MongoSessionSynchronization MongoDB specific transaction synchronization} within the subscriber
|
* Registers a {@link MongoSessionSynchronization MongoDB specific transaction synchronization} within the subscriber
|
||||||
* {@link Context} if {@link TransactionSynchronizationManager#isSynchronizationActive() synchronization is active}.
|
* {@link Context} if {@link TransactionSynchronizationManager#isSynchronizationActive() synchronization is active}.
|
||||||
*
|
*
|
||||||
@@ -119,7 +119,7 @@ public class ReactiveMongoDatabaseUtils {
|
|||||||
/**
|
/**
|
||||||
* Obtain the {@link MongoDatabase database} with given name form the given {@link ReactiveMongoDatabaseFactory
|
* Obtain the {@link MongoDatabase database} with given name form the given {@link ReactiveMongoDatabaseFactory
|
||||||
* factory}.
|
* factory}.
|
||||||
* <p />
|
* <br />
|
||||||
* Registers a {@link MongoSessionSynchronization MongoDB specific transaction synchronization} within the subscriber
|
* Registers a {@link MongoSessionSynchronization MongoDB specific transaction synchronization} within the subscriber
|
||||||
* {@link Context} if {@link TransactionSynchronizationManager#isSynchronizationActive() synchronization is active}.
|
* {@link Context} if {@link TransactionSynchronizationManager#isSynchronizationActive() synchronization is active}.
|
||||||
*
|
*
|
||||||
@@ -138,6 +138,10 @@ public class ReactiveMongoDatabaseUtils {
|
|||||||
|
|
||||||
Assert.notNull(factory, "DatabaseFactory must not be null!");
|
Assert.notNull(factory, "DatabaseFactory must not be null!");
|
||||||
|
|
||||||
|
if (sessionSynchronization == SessionSynchronization.NEVER) {
|
||||||
|
return getMongoDatabaseOrDefault(dbName, factory);
|
||||||
|
}
|
||||||
|
|
||||||
return TransactionSynchronizationManager.forCurrentTransaction()
|
return TransactionSynchronizationManager.forCurrentTransaction()
|
||||||
.filter(TransactionSynchronizationManager::isSynchronizationActive) //
|
.filter(TransactionSynchronizationManager::isSynchronizationActive) //
|
||||||
.flatMap(synchronizationManager -> {
|
.flatMap(synchronizationManager -> {
|
||||||
|
|||||||
@@ -1,5 +1,5 @@
|
|||||||
/*
|
/*
|
||||||
* Copyright 2019-2021 the original author or authors.
|
* Copyright 2019-2022 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,7 +24,7 @@ import com.mongodb.reactivestreams.client.ClientSession;
|
|||||||
/**
|
/**
|
||||||
* MongoDB specific resource holder, wrapping a {@link ClientSession}. {@link ReactiveMongoTransactionManager} binds
|
* MongoDB specific resource holder, wrapping a {@link ClientSession}. {@link ReactiveMongoTransactionManager} binds
|
||||||
* instances of this class to the subscriber context.
|
* instances of this class to the subscriber context.
|
||||||
* <p />
|
* <br />
|
||||||
* <strong>Note:</strong> Intended for internal usage only.
|
* <strong>Note:</strong> Intended for internal usage only.
|
||||||
*
|
*
|
||||||
* @author Mark Paluch
|
* @author Mark Paluch
|
||||||
|
|||||||
@@ -1,5 +1,5 @@
|
|||||||
/*
|
/*
|
||||||
* Copyright 2019-2021 the original author or authors.
|
* Copyright 2019-2022 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.
|
||||||
@@ -38,21 +38,21 @@ import com.mongodb.reactivestreams.client.ClientSession;
|
|||||||
* A {@link org.springframework.transaction.ReactiveTransactionManager} implementation that manages
|
* A {@link org.springframework.transaction.ReactiveTransactionManager} implementation that manages
|
||||||
* {@link com.mongodb.reactivestreams.client.ClientSession} based transactions for a single
|
* {@link com.mongodb.reactivestreams.client.ClientSession} based transactions for a single
|
||||||
* {@link org.springframework.data.mongodb.ReactiveMongoDatabaseFactory}.
|
* {@link org.springframework.data.mongodb.ReactiveMongoDatabaseFactory}.
|
||||||
* <p />
|
* <br />
|
||||||
* Binds a {@link ClientSession} from the specified
|
* Binds a {@link ClientSession} from the specified
|
||||||
* {@link org.springframework.data.mongodb.ReactiveMongoDatabaseFactory} to the subscriber
|
* {@link org.springframework.data.mongodb.ReactiveMongoDatabaseFactory} to the subscriber
|
||||||
* {@link reactor.util.context.Context}.
|
* {@link reactor.util.context.Context}.
|
||||||
* <p />
|
* <br />
|
||||||
* {@link org.springframework.transaction.TransactionDefinition#isReadOnly() Readonly} transactions operate on a
|
* {@link org.springframework.transaction.TransactionDefinition#isReadOnly() Readonly} transactions operate on a
|
||||||
* {@link ClientSession} and enable causal consistency, and also {@link ClientSession#startTransaction() start},
|
* {@link ClientSession} and enable causal consistency, and also {@link ClientSession#startTransaction() start},
|
||||||
* {@link com.mongodb.reactivestreams.client.ClientSession#commitTransaction() commit} or
|
* {@link com.mongodb.reactivestreams.client.ClientSession#commitTransaction() commit} or
|
||||||
* {@link ClientSession#abortTransaction() abort} a transaction.
|
* {@link ClientSession#abortTransaction() abort} a transaction.
|
||||||
* <p />
|
* <br />
|
||||||
* Application code is required to retrieve the {@link com.mongodb.reactivestreams.client.MongoDatabase} via
|
* Application code is required to retrieve the {@link com.mongodb.reactivestreams.client.MongoDatabase} via
|
||||||
* {@link org.springframework.data.mongodb.ReactiveMongoDatabaseUtils#getDatabase(ReactiveMongoDatabaseFactory)} instead
|
* {@link org.springframework.data.mongodb.ReactiveMongoDatabaseUtils#getDatabase(ReactiveMongoDatabaseFactory)} instead
|
||||||
* of a standard {@link org.springframework.data.mongodb.ReactiveMongoDatabaseFactory#getMongoDatabase()} call. Spring
|
* of a standard {@link org.springframework.data.mongodb.ReactiveMongoDatabaseFactory#getMongoDatabase()} call. Spring
|
||||||
* classes such as {@link org.springframework.data.mongodb.core.ReactiveMongoTemplate} use this strategy implicitly.
|
* classes such as {@link org.springframework.data.mongodb.core.ReactiveMongoTemplate} use this strategy implicitly.
|
||||||
* <p />
|
* <br />
|
||||||
* By default failure of a {@literal commit} operation raises a {@link TransactionSystemException}. You can override
|
* By default failure of a {@literal commit} operation raises a {@link TransactionSystemException}. You can override
|
||||||
* {@link #doCommit(TransactionSynchronizationManager, ReactiveMongoTransactionObject)} to implement the
|
* {@link #doCommit(TransactionSynchronizationManager, ReactiveMongoTransactionObject)} to implement the
|
||||||
* <a href="https://docs.mongodb.com/manual/core/transactions/#retry-commit-operation">Retry Commit Operation</a>
|
* <a href="https://docs.mongodb.com/manual/core/transactions/#retry-commit-operation">Retry Commit Operation</a>
|
||||||
@@ -71,11 +71,11 @@ public class ReactiveMongoTransactionManager extends AbstractReactiveTransaction
|
|||||||
|
|
||||||
/**
|
/**
|
||||||
* Create a new {@link ReactiveMongoTransactionManager} for bean-style usage.
|
* Create a new {@link ReactiveMongoTransactionManager} for bean-style usage.
|
||||||
* <p />
|
* <br />
|
||||||
* <strong>Note:</strong>The {@link org.springframework.data.mongodb.ReactiveMongoDatabaseFactory db factory} has to
|
* <strong>Note:</strong>The {@link org.springframework.data.mongodb.ReactiveMongoDatabaseFactory db factory} has to
|
||||||
* be {@link #setDatabaseFactory(ReactiveMongoDatabaseFactory)} set} before using the instance. Use this constructor
|
* be {@link #setDatabaseFactory(ReactiveMongoDatabaseFactory)} set} before using the instance. Use this constructor
|
||||||
* to prepare a {@link ReactiveMongoTransactionManager} via a {@link org.springframework.beans.factory.BeanFactory}.
|
* to prepare a {@link ReactiveMongoTransactionManager} via a {@link org.springframework.beans.factory.BeanFactory}.
|
||||||
* <p />
|
* <br />
|
||||||
* Optionally it is possible to set default {@link TransactionOptions transaction options} defining
|
* Optionally it is possible to set default {@link TransactionOptions transaction options} defining
|
||||||
* {@link com.mongodb.ReadConcern} and {@link com.mongodb.WriteConcern}.
|
* {@link com.mongodb.ReadConcern} and {@link com.mongodb.WriteConcern}.
|
||||||
*
|
*
|
||||||
|
|||||||
@@ -1,5 +1,5 @@
|
|||||||
/*
|
/*
|
||||||
* Copyright 2018-2021 the original author or authors.
|
* Copyright 2018-2022 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.
|
||||||
@@ -35,7 +35,7 @@ import com.mongodb.session.ClientSession;
|
|||||||
/**
|
/**
|
||||||
* {@link MethodInterceptor} implementation looking up and invoking an alternative target method having
|
* {@link MethodInterceptor} implementation looking up and invoking an alternative target method having
|
||||||
* {@link ClientSession} as its first argument. This allows seamless integration with the existing code base.
|
* {@link ClientSession} as its first argument. This allows seamless integration with the existing code base.
|
||||||
* <p />
|
* <br />
|
||||||
* The {@link MethodInterceptor} is aware of methods on {@code MongoCollection} that my return new instances of itself
|
* The {@link MethodInterceptor} is aware of methods on {@code MongoCollection} that my return new instances of itself
|
||||||
* like (eg. {@link com.mongodb.reactivestreams.client.MongoCollection#withWriteConcern(WriteConcern)} and decorate them
|
* like (eg. {@link com.mongodb.reactivestreams.client.MongoCollection#withWriteConcern(WriteConcern)} and decorate them
|
||||||
* if not already proxied.
|
* if not already proxied.
|
||||||
|
|||||||
@@ -1,5 +1,5 @@
|
|||||||
/*
|
/*
|
||||||
* Copyright 2018-2021 the original author or authors.
|
* Copyright 2018-2022 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,13 +15,20 @@
|
|||||||
*/
|
*/
|
||||||
package org.springframework.data.mongodb;
|
package org.springframework.data.mongodb;
|
||||||
|
|
||||||
|
import org.springframework.data.mongodb.core.MongoTemplate;
|
||||||
|
import org.springframework.data.mongodb.core.ReactiveMongoTemplate;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* {@link SessionSynchronization} is used along with {@link org.springframework.data.mongodb.core.MongoTemplate} to
|
* {@link SessionSynchronization} is used along with {@code MongoTemplate} to define in which type of transactions to
|
||||||
* define in which type of transactions to participate if any.
|
* participate if any.
|
||||||
*
|
*
|
||||||
* @author Christoph Strobl
|
* @author Christoph Strobl
|
||||||
* @author Mark Paluch
|
* @author Mark Paluch
|
||||||
* @since 2.1
|
* @since 2.1
|
||||||
|
* @see MongoTemplate#setSessionSynchronization(SessionSynchronization)
|
||||||
|
* @see MongoDatabaseUtils#getDatabase(MongoDatabaseFactory, SessionSynchronization)
|
||||||
|
* @see ReactiveMongoTemplate#setSessionSynchronization(SessionSynchronization)
|
||||||
|
* @see ReactiveMongoDatabaseUtils#getDatabase(ReactiveMongoDatabaseFactory, SessionSynchronization)
|
||||||
*/
|
*/
|
||||||
public enum SessionSynchronization {
|
public enum SessionSynchronization {
|
||||||
|
|
||||||
@@ -34,5 +41,12 @@ public enum SessionSynchronization {
|
|||||||
/**
|
/**
|
||||||
* Synchronize with native MongoDB transactions initiated via {@link MongoTransactionManager}.
|
* Synchronize with native MongoDB transactions initiated via {@link MongoTransactionManager}.
|
||||||
*/
|
*/
|
||||||
ON_ACTUAL_TRANSACTION;
|
ON_ACTUAL_TRANSACTION,
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Do not participate in ongoing transactions.
|
||||||
|
*
|
||||||
|
* @since 3.2.5
|
||||||
|
*/
|
||||||
|
NEVER;
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -1,5 +1,5 @@
|
|||||||
/*
|
/*
|
||||||
* Copyright 2020-2021 the original author or authors.
|
* Copyright 2020-2022 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.
|
||||||
@@ -48,7 +48,7 @@ public class SpringDataMongoDB {
|
|||||||
|
|
||||||
/**
|
/**
|
||||||
* Fetches the "Implementation-Version" manifest attribute from the jar file.
|
* Fetches the "Implementation-Version" manifest attribute from the jar file.
|
||||||
* <p />
|
* <br />
|
||||||
* Note that some ClassLoaders do not expose the package metadata, hence this class might not be able to determine the
|
* Note that some ClassLoaders do not expose the package metadata, hence this class might not be able to determine the
|
||||||
* version in all environments. In this case the current Major version is returned as a fallback.
|
* version in all environments. In this case the current Major version is returned as a fallback.
|
||||||
*
|
*
|
||||||
|
|||||||
@@ -1,5 +1,5 @@
|
|||||||
/*
|
/*
|
||||||
* Copyright 2010-2021 the original author or authors.
|
* Copyright 2010-2022 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-2021 the original author or authors.
|
* Copyright 2018-2022 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-2021 the original author or authors.
|
* Copyright 2016-2022 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-2021 the original author or authors.
|
* Copyright 2011-2022 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-2021 the original author or authors.
|
* Copyright 2019-2022 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-2021 the original author or authors.
|
* Copyright 2013-2022 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-2021 the original author or authors.
|
* Copyright 2020-2022 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-2021 the original author or authors.
|
* Copyright 2015-2022 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-2021 the original author or authors.
|
* Copyright 2013-2022 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-2021 the original author or authors.
|
* Copyright 2011-2022 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,7 +24,6 @@ import java.util.List;
|
|||||||
import java.util.Set;
|
import java.util.Set;
|
||||||
|
|
||||||
import org.springframework.beans.BeanMetadataElement;
|
import org.springframework.beans.BeanMetadataElement;
|
||||||
import org.springframework.beans.factory.NoSuchBeanDefinitionException;
|
|
||||||
import org.springframework.beans.factory.config.BeanDefinition;
|
import org.springframework.beans.factory.config.BeanDefinition;
|
||||||
import org.springframework.beans.factory.config.BeanDefinitionHolder;
|
import org.springframework.beans.factory.config.BeanDefinitionHolder;
|
||||||
import org.springframework.beans.factory.config.RuntimeBeanReference;
|
import org.springframework.beans.factory.config.RuntimeBeanReference;
|
||||||
@@ -64,6 +63,7 @@ import org.springframework.util.Assert;
|
|||||||
import org.springframework.util.ClassUtils;
|
import org.springframework.util.ClassUtils;
|
||||||
import org.springframework.util.StringUtils;
|
import org.springframework.util.StringUtils;
|
||||||
import org.springframework.util.xml.DomUtils;
|
import org.springframework.util.xml.DomUtils;
|
||||||
|
|
||||||
import org.w3c.dom.Element;
|
import org.w3c.dom.Element;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
@@ -135,9 +135,7 @@ public class MappingMongoConverterParser implements BeanDefinitionParser {
|
|||||||
new BeanComponentDefinition(indexOperationsProviderBuilder.getBeanDefinition(), "indexOperationsProvider"));
|
new BeanComponentDefinition(indexOperationsProviderBuilder.getBeanDefinition(), "indexOperationsProvider"));
|
||||||
}
|
}
|
||||||
|
|
||||||
try {
|
if (!registry.containsBeanDefinition(INDEX_HELPER_BEAN_NAME)) {
|
||||||
registry.getBeanDefinition(INDEX_HELPER_BEAN_NAME);
|
|
||||||
} catch (NoSuchBeanDefinitionException ignored) {
|
|
||||||
|
|
||||||
BeanDefinitionBuilder indexHelperBuilder = BeanDefinitionBuilder
|
BeanDefinitionBuilder indexHelperBuilder = BeanDefinitionBuilder
|
||||||
.genericBeanDefinition(MongoPersistentEntityIndexCreator.class);
|
.genericBeanDefinition(MongoPersistentEntityIndexCreator.class);
|
||||||
@@ -151,7 +149,7 @@ public class MappingMongoConverterParser implements BeanDefinitionParser {
|
|||||||
|
|
||||||
BeanDefinition validatingMongoEventListener = potentiallyCreateValidatingMongoEventListener(element, parserContext);
|
BeanDefinition validatingMongoEventListener = potentiallyCreateValidatingMongoEventListener(element, parserContext);
|
||||||
|
|
||||||
if (validatingMongoEventListener != null) {
|
if (validatingMongoEventListener != null && !registry.containsBeanDefinition(VALIDATING_EVENT_LISTENER_BEAN_NAME)) {
|
||||||
parserContext.registerBeanComponent(
|
parserContext.registerBeanComponent(
|
||||||
new BeanComponentDefinition(validatingMongoEventListener, VALIDATING_EVENT_LISTENER_BEAN_NAME));
|
new BeanComponentDefinition(validatingMongoEventListener, VALIDATING_EVENT_LISTENER_BEAN_NAME));
|
||||||
}
|
}
|
||||||
@@ -165,15 +163,16 @@ public class MappingMongoConverterParser implements BeanDefinitionParser {
|
|||||||
private BeanDefinition potentiallyCreateValidatingMongoEventListener(Element element, ParserContext parserContext) {
|
private BeanDefinition potentiallyCreateValidatingMongoEventListener(Element element, ParserContext parserContext) {
|
||||||
|
|
||||||
String disableValidation = element.getAttribute("disable-validation");
|
String disableValidation = element.getAttribute("disable-validation");
|
||||||
boolean validationDisabled = StringUtils.hasText(disableValidation) && Boolean.valueOf(disableValidation);
|
boolean validationDisabled = StringUtils.hasText(disableValidation) && Boolean.parseBoolean(disableValidation);
|
||||||
|
|
||||||
if (!validationDisabled) {
|
if (!validationDisabled) {
|
||||||
|
|
||||||
BeanDefinitionBuilder builder = BeanDefinitionBuilder.genericBeanDefinition();
|
BeanDefinitionBuilder builder = BeanDefinitionBuilder.genericBeanDefinition();
|
||||||
RuntimeBeanReference validator = getValidator(builder, parserContext);
|
RuntimeBeanReference validator = getValidator(element, parserContext);
|
||||||
|
|
||||||
if (validator != null) {
|
if (validator != null) {
|
||||||
builder.getRawBeanDefinition().setBeanClass(ValidatingMongoEventListener.class);
|
builder.getRawBeanDefinition().setBeanClass(ValidatingMongoEventListener.class);
|
||||||
|
builder.getRawBeanDefinition().setSource(element);
|
||||||
builder.addConstructorArgValue(validator);
|
builder.addConstructorArgValue(validator);
|
||||||
|
|
||||||
return builder.getBeanDefinition();
|
return builder.getBeanDefinition();
|
||||||
@@ -195,7 +194,6 @@ public class MappingMongoConverterParser implements BeanDefinitionParser {
|
|||||||
validatorDef.setSource(source);
|
validatorDef.setSource(source);
|
||||||
validatorDef.setRole(BeanDefinition.ROLE_INFRASTRUCTURE);
|
validatorDef.setRole(BeanDefinition.ROLE_INFRASTRUCTURE);
|
||||||
String validatorName = parserContext.getReaderContext().registerWithGeneratedName(validatorDef);
|
String validatorName = parserContext.getReaderContext().registerWithGeneratedName(validatorDef);
|
||||||
parserContext.registerBeanComponent(new BeanComponentDefinition(validatorDef, validatorName));
|
|
||||||
|
|
||||||
return new RuntimeBeanReference(validatorName);
|
return new RuntimeBeanReference(validatorName);
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -1,5 +1,5 @@
|
|||||||
/*
|
/*
|
||||||
* Copyright 2012-2021 the original author or authors.
|
* Copyright 2012-2022 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-2021 the original author or authors.
|
* Copyright 2013-2022 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-2021 the original author or authors.
|
* Copyright 2015-2022 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-2021 the original author or authors.
|
* Copyright 2016-2022 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,8 +172,7 @@ public abstract class MongoConfigurationSupport {
|
|||||||
|
|
||||||
/**
|
/**
|
||||||
* Configures whether to abbreviate field names for domain objects by configuring a
|
* Configures whether to abbreviate field names for domain objects by configuring a
|
||||||
* {@link CamelCaseAbbreviatingFieldNamingStrategy} on the {@link MongoMappingContext} instance created. For advanced
|
* {@link CamelCaseAbbreviatingFieldNamingStrategy} on the {@link MongoMappingContext} instance created.
|
||||||
* customization needs, consider overriding {@link #mappingMongoConverter()}.
|
|
||||||
*
|
*
|
||||||
* @return
|
* @return
|
||||||
*/
|
*/
|
||||||
|
|||||||
@@ -1,5 +1,5 @@
|
|||||||
/*
|
/*
|
||||||
* Copyright 2015-2021 the original author or authors.
|
* Copyright 2015-2022 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-2021 the original author or authors.
|
* Copyright 2011-2022 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-2021 the original author or authors.
|
* Copyright 2011-2022 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-2021 the original author or authors.
|
* Copyright 2011-2022 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-2021 the original author or authors.
|
* Copyright 2011-2022 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.
|
||||||
@@ -22,9 +22,12 @@ import java.util.Map;
|
|||||||
import org.springframework.beans.factory.config.BeanDefinition;
|
import org.springframework.beans.factory.config.BeanDefinition;
|
||||||
import org.springframework.beans.factory.config.CustomEditorConfigurer;
|
import org.springframework.beans.factory.config.CustomEditorConfigurer;
|
||||||
import org.springframework.beans.factory.support.BeanDefinitionBuilder;
|
import org.springframework.beans.factory.support.BeanDefinitionBuilder;
|
||||||
|
import org.springframework.beans.factory.support.BeanDefinitionValidationException;
|
||||||
import org.springframework.beans.factory.support.ManagedMap;
|
import org.springframework.beans.factory.support.ManagedMap;
|
||||||
import org.springframework.beans.factory.xml.BeanDefinitionParser;
|
import org.springframework.beans.factory.xml.BeanDefinitionParser;
|
||||||
import org.springframework.data.mongodb.core.MongoClientSettingsFactoryBean;
|
import org.springframework.data.mongodb.core.MongoClientSettingsFactoryBean;
|
||||||
|
import org.springframework.data.mongodb.core.MongoServerApiFactoryBean;
|
||||||
|
import org.springframework.util.StringUtils;
|
||||||
import org.springframework.util.xml.DomUtils;
|
import org.springframework.util.xml.DomUtils;
|
||||||
import org.w3c.dom.Element;
|
import org.w3c.dom.Element;
|
||||||
|
|
||||||
@@ -112,6 +115,20 @@ abstract class MongoParsingUtils {
|
|||||||
// Field level encryption
|
// Field level encryption
|
||||||
setPropertyReference(clientOptionsDefBuilder, settingsElement, "encryption-settings-ref", "autoEncryptionSettings");
|
setPropertyReference(clientOptionsDefBuilder, settingsElement, "encryption-settings-ref", "autoEncryptionSettings");
|
||||||
|
|
||||||
|
// ServerAPI
|
||||||
|
if (StringUtils.hasText(settingsElement.getAttribute("server-api-version"))) {
|
||||||
|
|
||||||
|
MongoServerApiFactoryBean serverApiFactoryBean = new MongoServerApiFactoryBean();
|
||||||
|
serverApiFactoryBean.setVersion(settingsElement.getAttribute("server-api-version"));
|
||||||
|
try {
|
||||||
|
clientOptionsDefBuilder.addPropertyValue("serverApi", serverApiFactoryBean.getObject());
|
||||||
|
} catch (Exception exception) {
|
||||||
|
throw new BeanDefinitionValidationException("Non parsable server-api.", exception);
|
||||||
|
}
|
||||||
|
} else {
|
||||||
|
setPropertyReference(clientOptionsDefBuilder, settingsElement, "server-api-ref", "serverApi");
|
||||||
|
}
|
||||||
|
|
||||||
// and the rest
|
// and the rest
|
||||||
|
|
||||||
mongoClientBuilder.addPropertyValue("mongoClientSettings", clientOptionsDefBuilder.getBeanDefinition());
|
mongoClientBuilder.addPropertyValue("mongoClientSettings", clientOptionsDefBuilder.getBeanDefinition());
|
||||||
|
|||||||
@@ -1,5 +1,5 @@
|
|||||||
/*
|
/*
|
||||||
* Copyright 2011-2021 the original author or authors.
|
* Copyright 2011-2022 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-2021 the original author or authors.
|
* Copyright 2020-2022 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.
|
||||||
@@ -28,7 +28,7 @@ import org.springframework.data.mongodb.core.convert.MappingMongoConverter;
|
|||||||
* @author Christoph Strobl
|
* @author Christoph Strobl
|
||||||
* @since 3.1
|
* @since 3.1
|
||||||
*/
|
*/
|
||||||
class PersistentEntitiesFactoryBean implements FactoryBean<PersistentEntities> {
|
public class PersistentEntitiesFactoryBean implements FactoryBean<PersistentEntities> {
|
||||||
|
|
||||||
private final MappingMongoConverter converter;
|
private final MappingMongoConverter converter;
|
||||||
|
|
||||||
|
|||||||
@@ -1,5 +1,5 @@
|
|||||||
/*
|
/*
|
||||||
* Copyright 2020-2021 the original author or authors.
|
* Copyright 2020-2022 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-2021 the original author or authors.
|
* Copyright 2019-2022 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-2021 the original author or authors.
|
* Copyright 2015-2022 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-2021 the original author or authors.
|
* Copyright 2011-2022 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-2021 the original author or authors.
|
* Copyright 2012-2022 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-2021 the original author or authors.
|
* Copyright 2020-2022 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-2021 the original author or authors.
|
* Copyright 2011-2022 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-2021 the original author or authors.
|
* Copyright 2018-2022 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-2021 the original author or authors.
|
* Copyright 2015-2022 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-2021 the original author or authors.
|
* Copyright 2018-2022 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-2021 the original author or authors.
|
* Copyright 2018-2022 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.
|
||||||
@@ -242,13 +242,13 @@ public class ChangeStreamOptions {
|
|||||||
|
|
||||||
/**
|
/**
|
||||||
* Set the filter to apply.
|
* Set the filter to apply.
|
||||||
* <p/>
|
* <br />
|
||||||
* Fields on aggregation expression root level are prefixed to map to fields contained in
|
* Fields on aggregation expression root level are prefixed to map to fields contained in
|
||||||
* {@link ChangeStreamDocument#getFullDocument() fullDocument}. However {@literal operationType}, {@literal ns},
|
* {@link ChangeStreamDocument#getFullDocument() fullDocument}. However {@literal operationType}, {@literal ns},
|
||||||
* {@literal documentKey} and {@literal fullDocument} are reserved words that will be omitted, and therefore taken
|
* {@literal documentKey} and {@literal fullDocument} are reserved words that will be omitted, and therefore taken
|
||||||
* as given, during the mapping procedure. You may want to have a look at the
|
* as given, during the mapping procedure. You may want to have a look at the
|
||||||
* <a href="https://docs.mongodb.com/manual/reference/change-events/">structure of Change Events</a>.
|
* <a href="https://docs.mongodb.com/manual/reference/change-events/">structure of Change Events</a>.
|
||||||
* <p/>
|
* <br />
|
||||||
* Use {@link org.springframework.data.mongodb.core.aggregation.TypedAggregation} to ensure filter expressions are
|
* Use {@link org.springframework.data.mongodb.core.aggregation.TypedAggregation} to ensure filter expressions are
|
||||||
* mapped to domain type fields.
|
* mapped to domain type fields.
|
||||||
*
|
*
|
||||||
|
|||||||
@@ -1,5 +1,5 @@
|
|||||||
/*
|
/*
|
||||||
* Copyright 2010-2021 the original author or authors.
|
* Copyright 2010-2022 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-2021 the original author or authors.
|
* Copyright 2010-2022 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,8 +17,11 @@ package org.springframework.data.mongodb.core;
|
|||||||
|
|
||||||
import java.util.Optional;
|
import java.util.Optional;
|
||||||
|
|
||||||
|
import org.springframework.data.mongodb.core.mapping.Field;
|
||||||
import org.springframework.data.mongodb.core.query.Collation;
|
import org.springframework.data.mongodb.core.query.Collation;
|
||||||
import org.springframework.data.mongodb.core.schema.MongoJsonSchema;
|
import org.springframework.data.mongodb.core.schema.MongoJsonSchema;
|
||||||
|
import org.springframework.data.mongodb.core.timeseries.Granularity;
|
||||||
|
import org.springframework.data.mongodb.core.timeseries.GranularityDefinition;
|
||||||
import org.springframework.data.mongodb.core.validation.Validator;
|
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;
|
||||||
@@ -42,6 +45,7 @@ public class CollectionOptions {
|
|||||||
private @Nullable Boolean capped;
|
private @Nullable Boolean capped;
|
||||||
private @Nullable Collation collation;
|
private @Nullable Collation collation;
|
||||||
private ValidationOptions validationOptions;
|
private ValidationOptions validationOptions;
|
||||||
|
private @Nullable TimeSeriesOptions timeSeriesOptions;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Constructs a new <code>CollectionOptions</code> instance.
|
* Constructs a new <code>CollectionOptions</code> instance.
|
||||||
@@ -54,17 +58,19 @@ public class CollectionOptions {
|
|||||||
*/
|
*/
|
||||||
@Deprecated
|
@Deprecated
|
||||||
public CollectionOptions(@Nullable Long size, @Nullable Long maxDocuments, @Nullable Boolean capped) {
|
public CollectionOptions(@Nullable Long size, @Nullable Long maxDocuments, @Nullable Boolean capped) {
|
||||||
this(size, maxDocuments, capped, null, ValidationOptions.none());
|
this(size, maxDocuments, capped, null, ValidationOptions.none(), null);
|
||||||
}
|
}
|
||||||
|
|
||||||
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) {
|
||||||
|
|
||||||
this.maxDocuments = maxDocuments;
|
this.maxDocuments = maxDocuments;
|
||||||
this.size = size;
|
this.size = size;
|
||||||
this.capped = capped;
|
this.capped = capped;
|
||||||
this.collation = collation;
|
this.collation = collation;
|
||||||
this.validationOptions = validationOptions;
|
this.validationOptions = validationOptions;
|
||||||
|
this.timeSeriesOptions = timeSeriesOptions;
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
@@ -78,7 +84,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());
|
return new CollectionOptions(null, null, null, collation, ValidationOptions.none(), null);
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
@@ -88,7 +94,21 @@ 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());
|
return new CollectionOptions(null, null, null, null, ValidationOptions.none(), null);
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Quick way to set up {@link CollectionOptions} for a Time Series collection. For more advanced settings use
|
||||||
|
* {@link #timeSeries(TimeSeriesOptions)}.
|
||||||
|
*
|
||||||
|
* @param timeField The name of the property which contains the date in each time series document. Must not be
|
||||||
|
* {@literal null}.
|
||||||
|
* @return new instance of {@link CollectionOptions}.
|
||||||
|
* @see #timeSeries(TimeSeriesOptions)
|
||||||
|
* @since 3.3
|
||||||
|
*/
|
||||||
|
public static CollectionOptions timeSeries(String timeField) {
|
||||||
|
return empty().timeSeries(TimeSeriesOptions.timeSeries(timeField));
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
@@ -99,7 +119,7 @@ public class CollectionOptions {
|
|||||||
* @since 2.0
|
* @since 2.0
|
||||||
*/
|
*/
|
||||||
public CollectionOptions capped() {
|
public CollectionOptions capped() {
|
||||||
return new CollectionOptions(size, maxDocuments, true, collation, validationOptions);
|
return new CollectionOptions(size, maxDocuments, true, collation, validationOptions, null);
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
@@ -110,7 +130,7 @@ 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);
|
return new CollectionOptions(size, maxDocuments, capped, collation, validationOptions, timeSeriesOptions);
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
@@ -121,7 +141,7 @@ 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);
|
return new CollectionOptions(size, maxDocuments, capped, collation, validationOptions, timeSeriesOptions);
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
@@ -132,7 +152,7 @@ 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);
|
return new CollectionOptions(size, maxDocuments, capped, collation, validationOptions, timeSeriesOptions);
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
@@ -252,7 +272,20 @@ 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);
|
return new CollectionOptions(size, maxDocuments, capped, collation, validationOptions, timeSeriesOptions);
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Create new {@link CollectionOptions} with the given {@link TimeSeriesOptions}.
|
||||||
|
*
|
||||||
|
* @param timeSeriesOptions must not be {@literal null}.
|
||||||
|
* @return new instance of {@link CollectionOptions}.
|
||||||
|
* @since 3.3
|
||||||
|
*/
|
||||||
|
public CollectionOptions timeSeries(TimeSeriesOptions timeSeriesOptions) {
|
||||||
|
|
||||||
|
Assert.notNull(timeSeriesOptions, "TimeSeriesOptions must not be null!");
|
||||||
|
return new CollectionOptions(size, maxDocuments, capped, collation, validationOptions, timeSeriesOptions);
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
@@ -303,6 +336,16 @@ public class CollectionOptions {
|
|||||||
return validationOptions.isEmpty() ? Optional.empty() : Optional.of(validationOptions);
|
return validationOptions.isEmpty() ? Optional.empty() : Optional.of(validationOptions);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Get the {@link TimeSeriesOptions} if available.
|
||||||
|
*
|
||||||
|
* @return {@link Optional#empty()} if not specified.
|
||||||
|
* @since 3.3
|
||||||
|
*/
|
||||||
|
public Optional<TimeSeriesOptions> getTimeSeriesOptions() {
|
||||||
|
return Optional.ofNullable(timeSeriesOptions);
|
||||||
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Encapsulation of ValidationOptions options.
|
* Encapsulation of ValidationOptions options.
|
||||||
*
|
*
|
||||||
@@ -385,7 +428,7 @@ public class CollectionOptions {
|
|||||||
/**
|
/**
|
||||||
* Get the {@code validationAction} to perform.
|
* Get the {@code validationAction} to perform.
|
||||||
*
|
*
|
||||||
* @return @return {@link Optional#empty()} if not set.
|
* @return {@link Optional#empty()} if not set.
|
||||||
*/
|
*/
|
||||||
public Optional<ValidationAction> getValidationAction() {
|
public Optional<ValidationAction> getValidationAction() {
|
||||||
return Optional.ofNullable(validationAction);
|
return Optional.ofNullable(validationAction);
|
||||||
@@ -398,4 +441,89 @@ public class CollectionOptions {
|
|||||||
return !Optionals.isAnyPresent(getValidator(), getValidationAction(), getValidationLevel());
|
return !Optionals.isAnyPresent(getValidator(), getValidationAction(), getValidationLevel());
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Options applicable to Time Series collections.
|
||||||
|
*
|
||||||
|
* @author Christoph Strobl
|
||||||
|
* @since 3.3
|
||||||
|
* @see <a href=
|
||||||
|
* "https://docs.mongodb.com/manual/core/timeseries-collections">https://docs.mongodb.com/manual/core/timeseries-collections</a>
|
||||||
|
*/
|
||||||
|
public static class TimeSeriesOptions {
|
||||||
|
|
||||||
|
private final String timeField;
|
||||||
|
|
||||||
|
private @Nullable final String metaField;
|
||||||
|
|
||||||
|
private final GranularityDefinition granularity;
|
||||||
|
|
||||||
|
private TimeSeriesOptions(String timeField, @Nullable String metaField, GranularityDefinition granularity) {
|
||||||
|
|
||||||
|
Assert.hasText(timeField, "Time field must not be empty or null!");
|
||||||
|
|
||||||
|
this.timeField = timeField;
|
||||||
|
this.metaField = metaField;
|
||||||
|
this.granularity = granularity;
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Create a new instance of {@link TimeSeriesOptions} using the given field as its {@literal timeField}. The one,
|
||||||
|
* that contains the date in each time series document. <br />
|
||||||
|
* {@link Field#name() Annotated fieldnames} will be considered during the mapping process.
|
||||||
|
*
|
||||||
|
* @param timeField must not be {@literal null}.
|
||||||
|
* @return new instance of {@link TimeSeriesOptions}.
|
||||||
|
*/
|
||||||
|
public static TimeSeriesOptions timeSeries(String timeField) {
|
||||||
|
return new TimeSeriesOptions(timeField, null, Granularity.DEFAULT);
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Set the name of the field which contains metadata in each time series document. Should not be the {@literal id}
|
||||||
|
* nor {@link TimeSeriesOptions#timeSeries(String)} timeField} nor point to an {@literal array} or
|
||||||
|
* {@link java.util.Collection}. <br />
|
||||||
|
* {@link Field#name() Annotated fieldnames} will be considered during the mapping process.
|
||||||
|
*
|
||||||
|
* @param metaField must not be {@literal null}.
|
||||||
|
* @return new instance of {@link TimeSeriesOptions}.
|
||||||
|
*/
|
||||||
|
public TimeSeriesOptions metaField(String metaField) {
|
||||||
|
return new TimeSeriesOptions(timeField, metaField, granularity);
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Select the {@link GranularityDefinition} parameter to define how data in the time series collection is organized.
|
||||||
|
* Select one that is closest to the time span between incoming measurements.
|
||||||
|
*
|
||||||
|
* @return new instance of {@link TimeSeriesOptions}.
|
||||||
|
* @see Granularity
|
||||||
|
*/
|
||||||
|
public TimeSeriesOptions granularity(GranularityDefinition granularity) {
|
||||||
|
return new TimeSeriesOptions(timeField, metaField, granularity);
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* @return never {@literal null}.
|
||||||
|
*/
|
||||||
|
public String getTimeField() {
|
||||||
|
return timeField;
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* @return can be {@literal null}. Might be an {@literal empty} {@link String} as well, so maybe check via
|
||||||
|
* {@link org.springframework.util.StringUtils#hasText(String)}.
|
||||||
|
*/
|
||||||
|
@Nullable
|
||||||
|
public String getMetaField() {
|
||||||
|
return metaField;
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* @return never {@literal null}.
|
||||||
|
*/
|
||||||
|
public GranularityDefinition getGranularity() {
|
||||||
|
return granularity;
|
||||||
|
}
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -1,5 +1,5 @@
|
|||||||
/*
|
/*
|
||||||
* Copyright 2019-2021 the original author or authors.
|
* Copyright 2019-2022 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.
|
||||||
@@ -176,16 +176,20 @@ 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 andElements = (Collection) $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))));
|
||||||
|
|||||||
@@ -1,5 +1,5 @@
|
|||||||
/*
|
/*
|
||||||
* Copyright 2002-2021 the original author or authors.
|
* Copyright 2002-2022 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-2021 the original author or authors.
|
* Copyright 2010-2022 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-2021 the original author or authors.
|
* Copyright 2015-2022 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-2021 the original author or authors.
|
* Copyright 2011-2022 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.
|
||||||
@@ -188,7 +188,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-2021 the original author or authors.
|
* Copyright 2016-2022 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-2021 the original author or authors.
|
* Copyright 2016-2022 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-2021 the original author or authors.
|
* Copyright 2014-2022 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-2021 the original author or authors.
|
* Copyright 2015-2022 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-2021 the original author or authors.
|
* Copyright 2010-2022 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,29 @@
|
|||||||
|
/*
|
||||||
|
* Copyright 2021-2022 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;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Encryption algorithms supported by MongoDB Client Side Field Level Encryption.
|
||||||
|
*
|
||||||
|
* @author Christoph Strobl
|
||||||
|
* @since 3.3
|
||||||
|
*/
|
||||||
|
public final class EncryptionAlgorithms {
|
||||||
|
|
||||||
|
public static final String AEAD_AES_256_CBC_HMAC_SHA_512_Deterministic = "AEAD_AES_256_CBC_HMAC_SHA_512-Deterministic";
|
||||||
|
public static final String AEAD_AES_256_CBC_HMAC_SHA_512_Random = "AEAD_AES_256_CBC_HMAC_SHA_512-Random";
|
||||||
|
|
||||||
|
}
|
||||||
@@ -1,5 +1,5 @@
|
|||||||
/*
|
/*
|
||||||
* Copyright 2018-2021 the original author or authors.
|
* Copyright 2018-2022 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.
|
||||||
@@ -29,19 +29,23 @@ import org.springframework.data.mapping.PersistentEntity;
|
|||||||
import org.springframework.data.mapping.PersistentPropertyAccessor;
|
import org.springframework.data.mapping.PersistentPropertyAccessor;
|
||||||
import org.springframework.data.mapping.context.MappingContext;
|
import org.springframework.data.mapping.context.MappingContext;
|
||||||
import org.springframework.data.mapping.model.ConvertingPropertyAccessor;
|
import org.springframework.data.mapping.model.ConvertingPropertyAccessor;
|
||||||
|
import org.springframework.data.mongodb.core.CollectionOptions.TimeSeriesOptions;
|
||||||
import org.springframework.data.mongodb.core.convert.MongoWriter;
|
import org.springframework.data.mongodb.core.convert.MongoWriter;
|
||||||
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.mapping.MongoSimpleTypes;
|
import org.springframework.data.mongodb.core.mapping.MongoSimpleTypes;
|
||||||
|
import org.springframework.data.mongodb.core.mapping.TimeSeries;
|
||||||
import org.springframework.data.mongodb.core.query.Collation;
|
import org.springframework.data.mongodb.core.query.Collation;
|
||||||
import org.springframework.data.mongodb.core.query.Criteria;
|
import org.springframework.data.mongodb.core.query.Criteria;
|
||||||
import org.springframework.data.mongodb.core.query.Query;
|
import org.springframework.data.mongodb.core.query.Query;
|
||||||
|
import org.springframework.data.mongodb.core.timeseries.Granularity;
|
||||||
import org.springframework.lang.Nullable;
|
import org.springframework.lang.Nullable;
|
||||||
import org.springframework.util.Assert;
|
import org.springframework.util.Assert;
|
||||||
import org.springframework.util.ClassUtils;
|
import org.springframework.util.ClassUtils;
|
||||||
import org.springframework.util.LinkedMultiValueMap;
|
import org.springframework.util.LinkedMultiValueMap;
|
||||||
import org.springframework.util.MultiValueMap;
|
import org.springframework.util.MultiValueMap;
|
||||||
import org.springframework.util.ObjectUtils;
|
import org.springframework.util.ObjectUtils;
|
||||||
|
import org.springframework.util.StringUtils;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Common operations performed on an entity in the context of it's mapping metadata.
|
* Common operations performed on an entity in the context of it's mapping metadata.
|
||||||
@@ -134,7 +138,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) {
|
||||||
@@ -778,6 +789,24 @@ class EntityOperations {
|
|||||||
* @return
|
* @return
|
||||||
*/
|
*/
|
||||||
Optional<Collation> getCollation(Query query);
|
Optional<Collation> getCollation(Query query);
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Derive the applicable {@link CollectionOptions} for the given type.
|
||||||
|
*
|
||||||
|
* @return never {@literal null}.
|
||||||
|
* @since 3.3
|
||||||
|
*/
|
||||||
|
CollectionOptions getCollectionOptions();
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Map the fields of a given {@link TimeSeriesOptions} against the target domain type to consider potentially
|
||||||
|
* annotated field names.
|
||||||
|
*
|
||||||
|
* @param options must not be {@literal null}.
|
||||||
|
* @return never {@literal null}.
|
||||||
|
* @since 3.3
|
||||||
|
*/
|
||||||
|
TimeSeriesOptions mapTimeSeriesOptions(TimeSeriesOptions options);
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
@@ -817,6 +846,16 @@ class EntityOperations {
|
|||||||
|
|
||||||
return query.getCollation();
|
return query.getCollation();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public CollectionOptions getCollectionOptions() {
|
||||||
|
return CollectionOptions.empty();
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public TimeSeriesOptions mapTimeSeriesOptions(TimeSeriesOptions options) {
|
||||||
|
return options;
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
@@ -854,6 +893,58 @@ class EntityOperations {
|
|||||||
|
|
||||||
return Optional.ofNullable(entity.getCollation());
|
return Optional.ofNullable(entity.getCollation());
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public CollectionOptions getCollectionOptions() {
|
||||||
|
|
||||||
|
CollectionOptions collectionOptions = CollectionOptions.empty();
|
||||||
|
if (entity.hasCollation()) {
|
||||||
|
collectionOptions = collectionOptions.collation(entity.getCollation());
|
||||||
|
}
|
||||||
|
|
||||||
|
if (entity.isAnnotationPresent(TimeSeries.class)) {
|
||||||
|
|
||||||
|
TimeSeries timeSeries = entity.getRequiredAnnotation(TimeSeries.class);
|
||||||
|
|
||||||
|
if (entity.getPersistentProperty(timeSeries.timeField()) == null) {
|
||||||
|
throw new MappingException(String.format("Time series field '%s' does not exist in type %s",
|
||||||
|
timeSeries.timeField(), entity.getName()));
|
||||||
|
}
|
||||||
|
|
||||||
|
TimeSeriesOptions options = TimeSeriesOptions.timeSeries(timeSeries.timeField());
|
||||||
|
if (StringUtils.hasText(timeSeries.metaField())) {
|
||||||
|
|
||||||
|
if (entity.getPersistentProperty(timeSeries.metaField()) == null) {
|
||||||
|
throw new MappingException(
|
||||||
|
String.format("Meta field '%s' does not exist in type %s", timeSeries.metaField(), entity.getName()));
|
||||||
|
}
|
||||||
|
|
||||||
|
options = options.metaField(timeSeries.metaField());
|
||||||
|
}
|
||||||
|
if (!Granularity.DEFAULT.equals(timeSeries.granularity())) {
|
||||||
|
options = options.granularity(timeSeries.granularity());
|
||||||
|
}
|
||||||
|
collectionOptions = collectionOptions.timeSeries(options);
|
||||||
|
}
|
||||||
|
|
||||||
|
return collectionOptions;
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public TimeSeriesOptions mapTimeSeriesOptions(TimeSeriesOptions source) {
|
||||||
|
|
||||||
|
TimeSeriesOptions target = TimeSeriesOptions.timeSeries(mappedNameOrDefault(source.getTimeField()));
|
||||||
|
|
||||||
|
if (StringUtils.hasText(source.getMetaField())) {
|
||||||
|
target = target.metaField(mappedNameOrDefault(source.getMetaField()));
|
||||||
|
}
|
||||||
|
return target.granularity(source.getGranularity());
|
||||||
|
}
|
||||||
|
|
||||||
|
private String mappedNameOrDefault(String name) {
|
||||||
|
MongoPersistentProperty persistentProperty = entity.getPersistentProperty(name);
|
||||||
|
return persistentProperty != null ? persistentProperty.getFieldName() : name;
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -1,5 +1,5 @@
|
|||||||
/*
|
/*
|
||||||
* Copyright 2017-2021 the original author or authors.
|
* Copyright 2017-2022 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-2021 the original author or authors.
|
* Copyright 2017-2022 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-2021 the original author or authors.
|
* Copyright 2017-2022 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.
|
||||||
@@ -125,7 +125,7 @@ public interface ExecutableFindOperation {
|
|||||||
|
|
||||||
/**
|
/**
|
||||||
* Get the number of matching elements.
|
* Get the number of matching elements.
|
||||||
* <p />
|
* <br />
|
||||||
* This method uses an {@link com.mongodb.client.MongoCollection#countDocuments(org.bson.conversions.Bson, com.mongodb.client.model.CountOptions) aggregation
|
* This method uses an {@link com.mongodb.client.MongoCollection#countDocuments(org.bson.conversions.Bson, com.mongodb.client.model.CountOptions) aggregation
|
||||||
* execution} even for empty {@link Query queries} which may have an impact on performance, but guarantees shard,
|
* execution} even for empty {@link Query queries} which may have an impact on performance, but guarantees shard,
|
||||||
* session and transaction compliance. In case an inaccurate count satisfies the applications needs use
|
* session and transaction compliance. In case an inaccurate count satisfies the applications needs use
|
||||||
|
|||||||
@@ -1,5 +1,5 @@
|
|||||||
/*
|
/*
|
||||||
* Copyright 2017-2021 the original author or authors.
|
* Copyright 2017-2022 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-2021 the original author or authors.
|
* Copyright 2017-2022 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-2021 the original author or authors.
|
* Copyright 2017-2022 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-2021 the original author or authors.
|
* Copyright 2018-2022 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-2021 the original author or authors.
|
* Copyright 2018-2022 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-2021 the original author or authors.
|
* Copyright 2017-2022 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.
|
||||||
|
|||||||
Some files were not shown because too many files have changed in this diff Show More
Reference in New Issue
Block a user