Compare commits
197 Commits
3.0.0.RELE
...
3.1.7
| Author | SHA1 | Date | |
|---|---|---|---|
|
|
f52cc3be1f | ||
|
|
1bda93858c | ||
|
|
1808970daf | ||
|
|
558fc28cce | ||
|
|
16bef54f11 | ||
|
|
d68a812e1b | ||
|
|
ccb9f111d9 | ||
|
|
f64b177c8f | ||
|
|
c0c7ba767f | ||
|
|
7639701f3f | ||
|
|
b39b2591b6 | ||
|
|
65c8317e38 | ||
|
|
9d0f7bac6a | ||
|
|
6f50747d21 | ||
|
|
5cf1578ad3 | ||
|
|
78a59c45ca | ||
|
|
dccdfc8b4d | ||
|
|
e48239eb8f | ||
|
|
c3b4f61d29 | ||
|
|
22ed860b4a | ||
|
|
bf642ad3f7 | ||
|
|
fcd48539ea | ||
|
|
bf10f72a57 | ||
|
|
1c652cce1c | ||
|
|
dc2de878bc | ||
|
|
00cacc02ac | ||
|
|
811c2e5d7b | ||
|
|
200f3006bd | ||
|
|
1d6bea51ec | ||
|
|
7779ded45c | ||
|
|
918bf7c138 | ||
|
|
abe3b9f6d7 | ||
|
|
41c453cc83 | ||
|
|
77784d88c7 | ||
|
|
263c62c880 | ||
|
|
24ab8f67bb | ||
|
|
572ceb867e | ||
|
|
b7caea8602 | ||
|
|
3696f2144f | ||
|
|
b25c8acca6 | ||
|
|
00d6271468 | ||
|
|
bb603ba7b9 | ||
|
|
02eaa4cbd2 | ||
|
|
7429503c63 | ||
|
|
82f4e2276b | ||
|
|
e1bce7d942 | ||
|
|
8bf3d395be | ||
|
|
d3c00a93c0 | ||
|
|
0aa805e1a2 | ||
|
|
9dc1df3deb | ||
|
|
92a73a5cc0 | ||
|
|
910d66afb0 | ||
|
|
1b60eae771 | ||
|
|
60dfdd7de6 | ||
|
|
4ec48c376d | ||
|
|
dee2ba15a4 | ||
|
|
c3596a503c | ||
|
|
7dca5a2218 | ||
|
|
f493006ec9 | ||
|
|
a0d5c2bded | ||
|
|
c697fe57c9 | ||
|
|
8a23452fdc | ||
|
|
bec7023a43 | ||
|
|
89a7309707 | ||
|
|
55ec9c5e5b | ||
|
|
cbb4dcb025 | ||
|
|
a0bad13505 | ||
|
|
d13521ae5d | ||
|
|
51f1526214 | ||
|
|
d049d96952 | ||
|
|
885bf0eae9 | ||
|
|
2a8ffd53d8 | ||
|
|
d54ed61581 | ||
|
|
9e76da91a9 | ||
|
|
595fde7b04 | ||
|
|
01f4e73b48 | ||
|
|
2934c4886b | ||
|
|
080c798721 | ||
|
|
7cfb68e6be | ||
|
|
1e24abe8e5 | ||
|
|
a316d156dc | ||
|
|
6563b125eb | ||
|
|
c9251b1b29 | ||
|
|
373f07e176 | ||
|
|
f5e2bdc7ef | ||
|
|
30e63fffe2 | ||
|
|
83136b4e60 | ||
|
|
56697545a3 | ||
|
|
76eecc443e | ||
|
|
1f81806809 | ||
|
|
2d348be5b2 | ||
|
|
bbbe369093 | ||
|
|
5aa29fc7b8 | ||
|
|
05fc6546ff | ||
|
|
2c6e645a3d | ||
|
|
20f702512b | ||
|
|
ad77f23364 | ||
|
|
9af8a73290 | ||
|
|
aaa4557887 | ||
|
|
217be64a77 | ||
|
|
0ef852a8fc | ||
|
|
26f0a1c7f9 | ||
|
|
230c32041a | ||
|
|
4548d07826 | ||
|
|
b879ec8c0f | ||
|
|
c0581c4943 | ||
|
|
85022d24f3 | ||
|
|
b2927ab419 | ||
|
|
91c39e2825 | ||
|
|
965a34efd3 | ||
|
|
046cbb52a1 | ||
|
|
edfd07a3d0 | ||
|
|
b4befc36c0 | ||
|
|
6034fc1cbd | ||
|
|
61f4770b4a | ||
|
|
c9cfe7acd6 | ||
|
|
415ceeef63 | ||
|
|
1bdcb88430 | ||
|
|
1a134aa444 | ||
|
|
c1da95f5dc | ||
|
|
c9c005400c | ||
|
|
b388659c3f | ||
|
|
90aa7b8f89 | ||
|
|
542de64711 | ||
|
|
88b1f9fcb3 | ||
|
|
450365992a | ||
|
|
fd25f39236 | ||
|
|
a7e3ed2e37 | ||
|
|
5795a507bd | ||
|
|
22bd3e64be | ||
|
|
6e47d5c76e | ||
|
|
bfab233d2f | ||
|
|
c6f12ef0e2 | ||
|
|
707ad8e232 | ||
|
|
b1f5717d63 | ||
|
|
95c9789f43 | ||
|
|
8e84d397e2 | ||
|
|
2ea3ceda2d | ||
|
|
6a43f28466 | ||
|
|
a44a0034b7 | ||
|
|
0085c8063a | ||
|
|
873fffa202 | ||
|
|
41607b10d0 | ||
|
|
66fae82798 | ||
|
|
00aaf2145b | ||
|
|
430c166a2b | ||
|
|
79c647a4d8 | ||
|
|
1b5a22730b | ||
|
|
a8a364c2de | ||
|
|
6bafcea539 | ||
|
|
2c1a3cf03e | ||
|
|
6cb89d7452 | ||
|
|
2026f8729e | ||
|
|
bf89400182 | ||
|
|
6c8cb9eb85 | ||
|
|
966504dfa6 | ||
|
|
b266bd6feb | ||
|
|
a6a4a0b3b6 | ||
|
|
2a66cadaa6 | ||
|
|
a70629697b | ||
|
|
d52785533d | ||
|
|
cee1d976de | ||
|
|
f907dbc559 | ||
|
|
613d085bb7 | ||
|
|
94a64a156f | ||
|
|
41e60e5c25 | ||
|
|
a254576a6e | ||
|
|
390b5e7b7e | ||
|
|
66dcb8f662 | ||
|
|
2eaa2d38af | ||
|
|
1290898c2b | ||
|
|
c4ae269b14 | ||
|
|
a4ef46d641 | ||
|
|
a27939808b | ||
|
|
da7fc927fa | ||
|
|
f768906684 | ||
|
|
61a228f8ac | ||
|
|
837b333d7a | ||
|
|
ffd4166b65 | ||
|
|
083050fc3c | ||
|
|
efbf9c8305 | ||
|
|
4fdf171f7d | ||
|
|
76990f4915 | ||
|
|
4defad57c9 | ||
|
|
431f7e6b78 | ||
|
|
e5157f1c17 | ||
|
|
af091bf6be | ||
|
|
84ac0e8a85 | ||
|
|
2a150adc40 | ||
|
|
feb3018d19 | ||
|
|
3af7269dbb | ||
|
|
af39b422b6 | ||
|
|
8b50778350 | ||
|
|
ce2f8a7bf5 | ||
|
|
26fa0c8285 | ||
|
|
3fda554f81 | ||
|
|
c6a86226e0 |
@@ -1,27 +0,0 @@
|
|||||||
= Contributor Code of Conduct
|
|
||||||
|
|
||||||
As contributors and maintainers of this project, and in the interest of fostering an open and welcoming community, we pledge to respect all people who contribute through reporting issues, posting feature requests, updating documentation, submitting pull requests or patches, and other activities.
|
|
||||||
|
|
||||||
We are committed to making participation in this project a harassment-free experience for everyone, regardless of level of experience, gender, gender identity and expression, sexual orientation, disability, personal appearance, body size, race, ethnicity, age, religion, or nationality.
|
|
||||||
|
|
||||||
Examples of unacceptable behavior by participants include:
|
|
||||||
|
|
||||||
* The use of sexualized language or imagery
|
|
||||||
* Personal attacks
|
|
||||||
* Trolling or insulting/derogatory comments
|
|
||||||
* Public or private harassment
|
|
||||||
* Publishing other's private information, such as physical or electronic addresses,
|
|
||||||
without explicit permission
|
|
||||||
* Other unethical or unprofessional conduct
|
|
||||||
|
|
||||||
Project maintainers have the right and responsibility to remove, edit, or reject comments, commits, code, wiki edits, issues, and other contributions that are not aligned to this Code of Conduct, or to ban temporarily or permanently any contributor for other behaviors that they deem inappropriate, threatening, offensive, or harmful.
|
|
||||||
|
|
||||||
By adopting this Code of Conduct, project maintainers commit themselves to fairly and consistently applying these principles to every aspect of managing this project. Project maintainers who do not follow or enforce the Code of Conduct may be permanently removed from the project team.
|
|
||||||
|
|
||||||
This Code of Conduct applies both within project spaces and in public spaces when an individual is representing the project or its community.
|
|
||||||
|
|
||||||
Instances of abusive, harassing, or otherwise unacceptable behavior may be reported by contacting a project maintainer at spring-code-of-conduct@pivotal.io.
|
|
||||||
All complaints will be reviewed and investigated and will result in a response that is deemed necessary and appropriate to the circumstances.
|
|
||||||
Maintainers are obligated to maintain confidentiality with regard to the reporter of an incident.
|
|
||||||
|
|
||||||
This Code of Conduct is adapted from the https://contributor-covenant.org[Contributor Covenant], version 1.3.0, available at https://contributor-covenant.org/version/1/3/0/[contributor-covenant.org/version/1/3/0/].
|
|
||||||
173
Jenkinsfile
vendored
173
Jenkinsfile
vendored
@@ -3,7 +3,7 @@ pipeline {
|
|||||||
|
|
||||||
triggers {
|
triggers {
|
||||||
pollSCM 'H/10 * * * *'
|
pollSCM 'H/10 * * * *'
|
||||||
upstream(upstreamProjects: "spring-data-commons/master", threshold: hudson.model.Result.SUCCESS)
|
upstream(upstreamProjects: "spring-data-commons/2.4.x", threshold: hudson.model.Result.SUCCESS)
|
||||||
}
|
}
|
||||||
|
|
||||||
options {
|
options {
|
||||||
@@ -46,16 +46,16 @@ pipeline {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
stage('Publish JDK 14 + MongoDB 4.2') {
|
stage('Publish JDK 15 + MongoDB 4.2') {
|
||||||
when {
|
when {
|
||||||
changeset "ci/openjdk14-mongodb-4.2/**"
|
changeset "ci/openjdk15-mongodb-4.2/**"
|
||||||
}
|
}
|
||||||
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-openjdk14-with-mongodb-4.2.0", "ci/openjdk14-mongodb-4.2/")
|
def image = docker.build("springci/spring-data-openjdk15-with-mongodb-4.2.0", "ci/openjdk15-mongodb-4.2/")
|
||||||
docker.withRegistry('', 'hub.docker.com-springbuildmaster') {
|
docker.withRegistry('', 'hub.docker.com-springbuildmaster') {
|
||||||
image.push()
|
image.push()
|
||||||
}
|
}
|
||||||
@@ -68,94 +68,98 @@ pipeline {
|
|||||||
stage("test: baseline (jdk8)") {
|
stage("test: baseline (jdk8)") {
|
||||||
when {
|
when {
|
||||||
anyOf {
|
anyOf {
|
||||||
branch 'master'
|
branch '3.1.x'
|
||||||
not { triggeredBy 'UpstreamCause' }
|
not { triggeredBy 'UpstreamCause' }
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
agent {
|
agent {
|
||||||
docker {
|
label 'data'
|
||||||
image 'springci/spring-data-openjdk8-with-mongodb-4.2.0:latest'
|
|
||||||
label 'data'
|
|
||||||
args '-v $HOME:/tmp/jenkins-home'
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
options { timeout(time: 30, unit: 'MINUTES') }
|
options { timeout(time: 30, unit: 'MINUTES') }
|
||||||
steps {
|
steps {
|
||||||
sh 'rm -rf ?'
|
script {
|
||||||
sh 'mkdir -p /tmp/mongodb/db /tmp/mongodb/log'
|
docker.withRegistry('', 'hub.docker.com-springbuildmaster') {
|
||||||
sh 'mongod --setParameter transactionLifetimeLimitSeconds=90 --setParameter maxTransactionLockRequestTimeoutMillis=10000 --dbpath /tmp/mongodb/db --replSet rs0 --fork --logpath /tmp/mongodb/log/mongod.log &'
|
docker.image('springci/spring-data-openjdk8-with-mongodb-4.2.0:latest').inside('-v $HOME:/tmp/jenkins-home') {
|
||||||
sh 'sleep 10'
|
sh 'mkdir -p /tmp/mongodb/db /tmp/mongodb/log'
|
||||||
sh 'mongo --eval "rs.initiate({_id: \'rs0\', members:[{_id: 0, host: \'127.0.0.1:27017\'}]});"'
|
sh 'mongod --setParameter transactionLifetimeLimitSeconds=90 --setParameter maxTransactionLockRequestTimeoutMillis=10000 --dbpath /tmp/mongodb/db --replSet rs0 --fork --logpath /tmp/mongodb/log/mongod.log &'
|
||||||
sh 'sleep 15'
|
sh 'sleep 10'
|
||||||
sh 'MAVEN_OPTS="-Duser.name=jenkins -Duser.home=/tmp/jenkins-home" ./mvnw clean dependency:list test -Duser.name=jenkins -Dsort -U -B'
|
sh 'mongo --eval "rs.initiate({_id: \'rs0\', members:[{_id: 0, host: \'127.0.0.1:27017\'}]});"'
|
||||||
|
sh 'sleep 15'
|
||||||
|
sh 'MAVEN_OPTS="-Duser.name=jenkins -Duser.home=/tmp/jenkins-home" ./mvnw clean dependency:list test -Duser.name=jenkins -Dsort -U -B'
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
stage("Test other configurations") {
|
stage("Test other configurations") {
|
||||||
when {
|
when {
|
||||||
anyOf {
|
allOf {
|
||||||
branch 'master'
|
branch '3.1.x'
|
||||||
not { triggeredBy 'UpstreamCause' }
|
not { triggeredBy 'UpstreamCause' }
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
parallel {
|
parallel {
|
||||||
stage("test: mongodb 4.0 (jdk8)") {
|
stage("test: mongodb 4.0 (jdk8)") {
|
||||||
agent {
|
agent {
|
||||||
docker {
|
label 'data'
|
||||||
image 'springci/spring-data-openjdk8-with-mongodb-4.0:latest'
|
|
||||||
label 'data'
|
|
||||||
args '-v $HOME:/tmp/jenkins-home'
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
options { timeout(time: 30, unit: 'MINUTES') }
|
options { timeout(time: 30, unit: 'MINUTES') }
|
||||||
steps {
|
steps {
|
||||||
sh 'rm -rf ?'
|
script {
|
||||||
sh 'mkdir -p /tmp/mongodb/db /tmp/mongodb/log'
|
docker.withRegistry('', 'hub.docker.com-springbuildmaster') {
|
||||||
sh 'mongod --setParameter transactionLifetimeLimitSeconds=90 --setParameter maxTransactionLockRequestTimeoutMillis=10000 --dbpath /tmp/mongodb/db --replSet rs0 --fork --logpath /tmp/mongodb/log/mongod.log &'
|
docker.image('springci/spring-data-openjdk8-with-mongodb-4.0:latest').inside('-v $HOME:/tmp/jenkins-home') {
|
||||||
sh 'sleep 10'
|
sh 'mkdir -p /tmp/mongodb/db /tmp/mongodb/log'
|
||||||
sh 'mongo --eval "rs.initiate({_id: \'rs0\', members:[{_id: 0, host: \'127.0.0.1:27017\'}]});"'
|
sh 'mongod --setParameter transactionLifetimeLimitSeconds=90 --setParameter maxTransactionLockRequestTimeoutMillis=10000 --dbpath /tmp/mongodb/db --replSet rs0 --fork --logpath /tmp/mongodb/log/mongod.log &'
|
||||||
sh 'sleep 15'
|
sh 'sleep 10'
|
||||||
sh 'MAVEN_OPTS="-Duser.name=jenkins -Duser.home=/tmp/jenkins-home" ./mvnw clean dependency:list test -Duser.name=jenkins -Dsort -U -B'
|
sh 'mongo --eval "rs.initiate({_id: \'rs0\', members:[{_id: 0, host: \'127.0.0.1:27017\'}]});"'
|
||||||
|
sh 'sleep 15'
|
||||||
|
sh 'MAVEN_OPTS="-Duser.name=jenkins -Duser.home=/tmp/jenkins-home" ./mvnw clean dependency:list test -Duser.name=jenkins -Dsort -U -B'
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
stage("test: mongodb 4.2 (jdk8)") {
|
stage("test: mongodb 4.2 (jdk8)") {
|
||||||
agent {
|
agent {
|
||||||
docker {
|
label 'data'
|
||||||
image 'springci/spring-data-openjdk8-with-mongodb-4.2.0:latest'
|
|
||||||
label 'data'
|
|
||||||
args '-v $HOME:/tmp/jenkins-home'
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
options { timeout(time: 30, unit: 'MINUTES') }
|
options { timeout(time: 30, unit: 'MINUTES') }
|
||||||
steps {
|
steps {
|
||||||
sh 'rm -rf ?'
|
script {
|
||||||
sh 'mkdir -p /tmp/mongodb/db /tmp/mongodb/log'
|
docker.withRegistry('', 'hub.docker.com-springbuildmaster') {
|
||||||
sh 'mongod --setParameter transactionLifetimeLimitSeconds=90 --setParameter maxTransactionLockRequestTimeoutMillis=10000 --dbpath /tmp/mongodb/db --replSet rs0 --fork --logpath /tmp/mongodb/log/mongod.log &'
|
docker.image('springci/spring-data-openjdk8-with-mongodb-4.2.0:latest').inside('-v $HOME:/tmp/jenkins-home') {
|
||||||
sh 'sleep 10'
|
sh 'mkdir -p /tmp/mongodb/db /tmp/mongodb/log'
|
||||||
sh 'mongo --eval "rs.initiate({_id: \'rs0\', members:[{_id: 0, host: \'127.0.0.1:27017\'}]});"'
|
sh 'mongod --setParameter transactionLifetimeLimitSeconds=90 --setParameter maxTransactionLockRequestTimeoutMillis=10000 --dbpath /tmp/mongodb/db --replSet rs0 --fork --logpath /tmp/mongodb/log/mongod.log &'
|
||||||
sh 'sleep 15'
|
sh 'sleep 10'
|
||||||
sh 'MAVEN_OPTS="-Duser.name=jenkins -Duser.home=/tmp/jenkins-home" ./mvnw clean dependency:list test -Duser.name=jenkins -Dsort -U -B'
|
sh 'mongo --eval "rs.initiate({_id: \'rs0\', members:[{_id: 0, host: \'127.0.0.1:27017\'}]});"'
|
||||||
|
sh 'sleep 15'
|
||||||
|
sh 'MAVEN_OPTS="-Duser.name=jenkins -Duser.home=/tmp/jenkins-home" ./mvnw clean dependency:list test -Duser.name=jenkins -Dsort -U -B'
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
stage("test: baseline (jdk14)") {
|
stage("test: baseline (jdk15)") {
|
||||||
agent {
|
agent {
|
||||||
docker {
|
label 'data'
|
||||||
image 'springci/spring-data-openjdk14-with-mongodb-4.2.0:latest'
|
|
||||||
label 'data'
|
|
||||||
args '-v $HOME:/tmp/jenkins-home'
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
options { timeout(time: 30, unit: 'MINUTES') }
|
options { timeout(time: 30, unit: 'MINUTES') }
|
||||||
steps {
|
steps {
|
||||||
sh 'rm -rf ?'
|
script {
|
||||||
sh 'mkdir -p /tmp/mongodb/db /tmp/mongodb/log'
|
docker.withRegistry('', 'hub.docker.com-springbuildmaster') {
|
||||||
sh 'mongod --setParameter transactionLifetimeLimitSeconds=90 --setParameter maxTransactionLockRequestTimeoutMillis=10000 --dbpath /tmp/mongodb/db --replSet rs0 --fork --logpath /tmp/mongodb/log/mongod.log &'
|
docker.image('springci/spring-data-openjdk15-with-mongodb-4.2.0:latest').inside('-v $HOME:/tmp/jenkins-home') {
|
||||||
sh 'sleep 10'
|
sh 'mkdir -p /tmp/mongodb/db /tmp/mongodb/log'
|
||||||
sh 'mongo --eval "rs.initiate({_id: \'rs0\', members:[{_id: 0, host: \'127.0.0.1:27017\'}]});"'
|
sh 'mongod --setParameter transactionLifetimeLimitSeconds=90 --setParameter maxTransactionLockRequestTimeoutMillis=10000 --dbpath /tmp/mongodb/db --replSet rs0 --fork --logpath /tmp/mongodb/log/mongod.log &'
|
||||||
sh 'sleep 15'
|
sh 'sleep 10'
|
||||||
sh 'MAVEN_OPTS="-Duser.name=jenkins -Duser.home=/tmp/jenkins-home" ./mvnw -Pjava11 clean dependency:list test -Duser.name=jenkins -Dsort -U -B'
|
sh 'mongo --eval "rs.initiate({_id: \'rs0\', members:[{_id: 0, host: \'127.0.0.1:27017\'}]});"'
|
||||||
|
sh 'sleep 15'
|
||||||
|
sh 'MAVEN_OPTS="-Duser.name=jenkins -Duser.home=/tmp/jenkins-home" ./mvnw -Pjava11 clean dependency:list test -Duser.name=jenkins -Dsort -U -B'
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@@ -164,16 +168,12 @@ pipeline {
|
|||||||
stage('Release to artifactory') {
|
stage('Release to artifactory') {
|
||||||
when {
|
when {
|
||||||
anyOf {
|
anyOf {
|
||||||
branch 'master'
|
branch '3.1.x'
|
||||||
not { triggeredBy 'UpstreamCause' }
|
not { triggeredBy 'UpstreamCause' }
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
agent {
|
agent {
|
||||||
docker {
|
label 'data'
|
||||||
image 'adoptopenjdk/openjdk8:latest'
|
|
||||||
label 'data'
|
|
||||||
args '-v $HOME:/tmp/jenkins-home'
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
options { timeout(time: 20, unit: 'MINUTES') }
|
options { timeout(time: 20, unit: 'MINUTES') }
|
||||||
|
|
||||||
@@ -182,28 +182,29 @@ pipeline {
|
|||||||
}
|
}
|
||||||
|
|
||||||
steps {
|
steps {
|
||||||
sh 'rm -rf ?'
|
script {
|
||||||
sh 'MAVEN_OPTS="-Duser.name=jenkins -Duser.home=/tmp/jenkins-home" ./mvnw -Pci,artifactory ' +
|
docker.withRegistry('', 'hub.docker.com-springbuildmaster') {
|
||||||
'-Dartifactory.server=https://repo.spring.io ' +
|
docker.image('adoptopenjdk/openjdk8:latest').inside('-v $HOME:/tmp/jenkins-home') {
|
||||||
"-Dartifactory.username=${ARTIFACTORY_USR} " +
|
sh 'MAVEN_OPTS="-Duser.name=jenkins -Duser.home=/tmp/jenkins-home" ./mvnw -Pci,artifactory ' +
|
||||||
"-Dartifactory.password=${ARTIFACTORY_PSW} " +
|
'-Dartifactory.server=https://repo.spring.io ' +
|
||||||
"-Dartifactory.staging-repository=libs-snapshot-local " +
|
"-Dartifactory.username=${ARTIFACTORY_USR} " +
|
||||||
"-Dartifactory.build-name=spring-data-mongodb " +
|
"-Dartifactory.password=${ARTIFACTORY_PSW} " +
|
||||||
"-Dartifactory.build-number=${BUILD_NUMBER} " +
|
"-Dartifactory.staging-repository=libs-snapshot-local " +
|
||||||
'-Dmaven.test.skip=true clean deploy -U -B'
|
"-Dartifactory.build-name=spring-data-mongodb " +
|
||||||
|
"-Dartifactory.build-number=${BUILD_NUMBER} " +
|
||||||
|
'-Dmaven.test.skip=true clean deploy -U -B'
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
stage('Publish documentation') {
|
stage('Publish documentation') {
|
||||||
when {
|
when {
|
||||||
branch 'master'
|
branch '3.1.x'
|
||||||
}
|
}
|
||||||
agent {
|
agent {
|
||||||
docker {
|
label 'data'
|
||||||
image 'adoptopenjdk/openjdk8:latest'
|
|
||||||
label 'data'
|
|
||||||
args '-v $HOME:/tmp/jenkins-home'
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
options { timeout(time: 20, unit: 'MINUTES') }
|
options { timeout(time: 20, unit: 'MINUTES') }
|
||||||
|
|
||||||
@@ -212,12 +213,18 @@ pipeline {
|
|||||||
}
|
}
|
||||||
|
|
||||||
steps {
|
steps {
|
||||||
sh 'MAVEN_OPTS="-Duser.name=jenkins -Duser.home=/tmp/jenkins-home" ./mvnw -Pci,distribute ' +
|
script {
|
||||||
'-Dartifactory.server=https://repo.spring.io ' +
|
docker.withRegistry('', 'hub.docker.com-springbuildmaster') {
|
||||||
"-Dartifactory.username=${ARTIFACTORY_USR} " +
|
docker.image('adoptopenjdk/openjdk8:latest').inside('-v $HOME:/tmp/jenkins-home') {
|
||||||
"-Dartifactory.password=${ARTIFACTORY_PSW} " +
|
sh 'MAVEN_OPTS="-Duser.name=jenkins -Duser.home=/tmp/jenkins-home" ./mvnw -Pci,distribute ' +
|
||||||
"-Dartifactory.distribution-repository=temp-private-local " +
|
'-Dartifactory.server=https://repo.spring.io ' +
|
||||||
'-Dmaven.test.skip=true clean deploy -U -B'
|
"-Dartifactory.username=${ARTIFACTORY_USR} " +
|
||||||
|
"-Dartifactory.password=${ARTIFACTORY_PSW} " +
|
||||||
|
"-Dartifactory.distribution-repository=temp-private-local " +
|
||||||
|
'-Dmaven.test.skip=true clean deploy -U -B'
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
17
README.adoc
17
README.adoc
@@ -10,7 +10,7 @@ Key functional areas of Spring Data MongoDB are a POJO centric model for interac
|
|||||||
|
|
||||||
== Code of Conduct
|
== Code of Conduct
|
||||||
|
|
||||||
This project is governed by the link:CODE_OF_CONDUCT.adoc[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
|
||||||
|
|
||||||
@@ -237,18 +237,17 @@ If you are just starting out with Spring, try one of the https://spring.io/guide
|
|||||||
* If you are upgrading, check out the https://docs.spring.io/spring-data/mongodb/docs/current/changelog.txt[changelog] for "`new and noteworthy`" features.
|
* If you are upgrading, check out the https://docs.spring.io/spring-data/mongodb/docs/current/changelog.txt[changelog] for "`new and noteworthy`" features.
|
||||||
* Ask a question - we monitor https://stackoverflow.com[stackoverflow.com] for questions tagged with https://stackoverflow.com/tags/spring-data[`spring-data-mongodb`].
|
* Ask a question - we monitor https://stackoverflow.com[stackoverflow.com] for questions tagged with https://stackoverflow.com/tags/spring-data[`spring-data-mongodb`].
|
||||||
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://jira.spring.io/browse/DATAMONGO[jira.spring.io/browse/DATAMONGO].
|
* 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
|
||||||
|
|
||||||
Spring Data uses JIRA as issue tracking system to record bugs and feature requests. If you want to raise an issue, please follow the recommendations below:
|
Spring Data uses Github as issue tracking system to record bugs and feature requests.
|
||||||
|
If you want to raise an issue, please follow the recommendations below:
|
||||||
|
|
||||||
* Before you log a bug, please search the
|
* Before you log a bug, please search the https://github.com/spring-projects/spring-data-mongodb/issues[issue tracker] to see if someone has already reported the problem.
|
||||||
https://jira.spring.io/browse/DATAMONGO[issue tracker] to see if someone has already reported the problem.
|
* If the issue does not already exist, https://github.com/spring-projects/spring-data-mongodb/issues/new[create a new issue].
|
||||||
* If the issue doesn’t already exist, https://jira.spring.io/browse/DATAMONGO[create a new issue].
|
* 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 and JVM version.
|
* 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 JIRA `{code}…{code}` escapes before and after your text.
|
|
||||||
* If possible try to create a test-case or project that replicates the issue. Attach a link to your code or a compressed file containing your code.
|
|
||||||
|
|
||||||
== Building from Source
|
== Building from Source
|
||||||
|
|
||||||
|
|||||||
@@ -1,4 +1,4 @@
|
|||||||
FROM adoptopenjdk/openjdk14:latest
|
FROM adoptopenjdk/openjdk15:latest
|
||||||
|
|
||||||
ENV TZ=Etc/UTC
|
ENV TZ=Etc/UTC
|
||||||
ENV DEBIAN_FRONTEND=noninteractive
|
ENV DEBIAN_FRONTEND=noninteractive
|
||||||
14
pom.xml
14
pom.xml
@@ -5,7 +5,7 @@
|
|||||||
|
|
||||||
<groupId>org.springframework.data</groupId>
|
<groupId>org.springframework.data</groupId>
|
||||||
<artifactId>spring-data-mongodb-parent</artifactId>
|
<artifactId>spring-data-mongodb-parent</artifactId>
|
||||||
<version>3.0.0.RELEASE</version>
|
<version>3.1.7</version>
|
||||||
<packaging>pom</packaging>
|
<packaging>pom</packaging>
|
||||||
|
|
||||||
<name>Spring Data MongoDB</name>
|
<name>Spring Data MongoDB</name>
|
||||||
@@ -15,7 +15,7 @@
|
|||||||
<parent>
|
<parent>
|
||||||
<groupId>org.springframework.data.build</groupId>
|
<groupId>org.springframework.data.build</groupId>
|
||||||
<artifactId>spring-data-parent</artifactId>
|
<artifactId>spring-data-parent</artifactId>
|
||||||
<version>2.3.0.RELEASE</version>
|
<version>2.4.7</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.3.0.RELEASE</springdata.commons>
|
<springdata.commons>2.4.7</springdata.commons>
|
||||||
<mongo>4.0.3</mongo>
|
<mongo>4.1.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>
|
||||||
@@ -158,7 +158,11 @@
|
|||||||
<id>spring-libs-milestone</id>
|
<id>spring-libs-milestone</id>
|
||||||
<url>https://repo.spring.io/libs-milestone</url>
|
<url>https://repo.spring.io/libs-milestone</url>
|
||||||
</pluginRepository>
|
</pluginRepository>
|
||||||
|
<pluginRepository>
|
||||||
|
<id>bintray-plugins</id>
|
||||||
|
<name>bintray-plugins</name>
|
||||||
|
<url>https://jcenter.bintray.com</url>
|
||||||
|
</pluginRepository>
|
||||||
</pluginRepositories>
|
</pluginRepositories>
|
||||||
|
|
||||||
</project>
|
</project>
|
||||||
|
|||||||
@@ -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.0.0.RELEASE</version>
|
<version>3.1.7</version>
|
||||||
<relativePath>../pom.xml</relativePath>
|
<relativePath>../pom.xml</relativePath>
|
||||||
</parent>
|
</parent>
|
||||||
|
|
||||||
|
|||||||
@@ -1,5 +1,5 @@
|
|||||||
/*
|
/*
|
||||||
* Copyright 2017-2020 the original author or authors.
|
* Copyright 2017-2021 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-2020 the original author or authors.
|
* Copyright 2017-2021 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-2020 the original author or authors.
|
* Copyright 2017-2021 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-2020 the original author or authors.
|
* Copyright 2017-2021 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-2020 the original author or authors.
|
* Copyright 2017-2021 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-2020 the original author or authors.
|
* Copyright 2017-2021 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-2020 the original author or authors.
|
* Copyright 2017-2021 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.0.0.RELEASE</version>
|
<version>3.1.7</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.0.0.RELEASE</version>
|
<version>3.1.7</version>
|
||||||
<relativePath>../pom.xml</relativePath>
|
<relativePath>../pom.xml</relativePath>
|
||||||
</parent>
|
</parent>
|
||||||
|
|
||||||
@@ -136,6 +136,13 @@
|
|||||||
<optional>true</optional>
|
<optional>true</optional>
|
||||||
</dependency>
|
</dependency>
|
||||||
|
|
||||||
|
<dependency>
|
||||||
|
<groupId>io.reactivex.rxjava3</groupId>
|
||||||
|
<artifactId>rxjava</artifactId>
|
||||||
|
<version>${rxjava3}</version>
|
||||||
|
<optional>true</optional>
|
||||||
|
</dependency>
|
||||||
|
|
||||||
<!-- CDI -->
|
<!-- CDI -->
|
||||||
<!-- Dependency order required to build against CDI 1.0 and test with CDI 2.0 -->
|
<!-- Dependency order required to build against CDI 1.0 and test with CDI 2.0 -->
|
||||||
<dependency>
|
<dependency>
|
||||||
@@ -192,7 +199,14 @@
|
|||||||
<dependency>
|
<dependency>
|
||||||
<groupId>org.hibernate</groupId>
|
<groupId>org.hibernate</groupId>
|
||||||
<artifactId>hibernate-validator</artifactId>
|
<artifactId>hibernate-validator</artifactId>
|
||||||
<version>5.2.4.Final</version>
|
<version>5.4.3.Final</version>
|
||||||
|
<scope>test</scope>
|
||||||
|
</dependency>
|
||||||
|
|
||||||
|
<dependency>
|
||||||
|
<groupId>org.glassfish</groupId>
|
||||||
|
<artifactId>javax.el</artifactId>
|
||||||
|
<version>3.0.1-b11</version>
|
||||||
<scope>test</scope>
|
<scope>test</scope>
|
||||||
</dependency>
|
</dependency>
|
||||||
|
|
||||||
|
|||||||
@@ -1,5 +1,5 @@
|
|||||||
/*
|
/*
|
||||||
* Copyright 2015-2020 the original author or authors.
|
* Copyright 2015-2021 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-2020 the original author or authors.
|
* Copyright 2018-2021 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-2020 the original author or authors.
|
* Copyright 2017-2021 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-2020 the original author or authors.
|
* Copyright 2010-2021 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-2020 the original author or authors.
|
* Copyright 2013-2021 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-2020 the original author or authors.
|
* Copyright 2011-2021 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-2019 the original author or authors.
|
* Copyright 2011-2021 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-2020 the original author or authors.
|
* Copyright 2018-2021 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.
|
||||||
@@ -79,7 +79,7 @@ public class MongoDatabaseUtils {
|
|||||||
* @param factory the {@link MongoDatabaseFactory} to get the {@link MongoDatabase} from.
|
* @param factory the {@link MongoDatabaseFactory} to get the {@link MongoDatabase} from.
|
||||||
* @return the {@link MongoDatabase} that is potentially associated with a transactional {@link ClientSession}.
|
* @return the {@link MongoDatabase} that is potentially associated with a transactional {@link ClientSession}.
|
||||||
*/
|
*/
|
||||||
public static MongoDatabase getDatabase(String dbName, MongoDatabaseFactory factory) {
|
public static MongoDatabase getDatabase(@Nullable String dbName, MongoDatabaseFactory factory) {
|
||||||
return doGetMongoDatabase(dbName, factory, SessionSynchronization.ON_ACTUAL_TRANSACTION);
|
return doGetMongoDatabase(dbName, factory, SessionSynchronization.ON_ACTUAL_TRANSACTION);
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -94,7 +94,7 @@ public class MongoDatabaseUtils {
|
|||||||
* @param sessionSynchronization the synchronization to use. Must not be {@literal null}.
|
* @param sessionSynchronization the synchronization to use. Must not be {@literal null}.
|
||||||
* @return the {@link MongoDatabase} that is potentially associated with a transactional {@link ClientSession}.
|
* @return the {@link MongoDatabase} that is potentially associated with a transactional {@link ClientSession}.
|
||||||
*/
|
*/
|
||||||
public static MongoDatabase getDatabase(String dbName, MongoDatabaseFactory factory,
|
public static MongoDatabase getDatabase(@Nullable String dbName, MongoDatabaseFactory factory,
|
||||||
SessionSynchronization sessionSynchronization) {
|
SessionSynchronization sessionSynchronization) {
|
||||||
return doGetMongoDatabase(dbName, factory, sessionSynchronization);
|
return doGetMongoDatabase(dbName, factory, sessionSynchronization);
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -1,5 +1,5 @@
|
|||||||
/*
|
/*
|
||||||
* Copyright 2011-2020 the original author or authors.
|
* Copyright 2011-2021 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-2020 the original author or authors.
|
* Copyright 2018-2021 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-2020 the original author or authors.
|
* Copyright 2018-2021 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-2020 the original author or authors.
|
* Copyright 2018-2021 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-2020 the original author or authors.
|
* Copyright 2018-2021 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-2020 the original author or authors.
|
* Copyright 2016-2021 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-2020 the original author or authors.
|
* Copyright 2019-2021 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-2020 the original author or authors.
|
* Copyright 2019-2021 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-2020 the original author or authors.
|
* Copyright 2019-2021 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.
|
||||||
@@ -110,7 +110,7 @@ public class ReactiveMongoTransactionManager extends AbstractReactiveTransaction
|
|||||||
this.options = options;
|
this.options = options;
|
||||||
}
|
}
|
||||||
|
|
||||||
/*
|
/*
|
||||||
* (non-Javadoc)
|
* (non-Javadoc)
|
||||||
* @see org.springframework.transaction.reactive.AbstractReactiveTransactionManager#doGetTransaction(org.springframework.transaction.reactive.TransactionSynchronizationManager)
|
* @see org.springframework.transaction.reactive.AbstractReactiveTransactionManager#doGetTransaction(org.springframework.transaction.reactive.TransactionSynchronizationManager)
|
||||||
*/
|
*/
|
||||||
@@ -123,7 +123,7 @@ public class ReactiveMongoTransactionManager extends AbstractReactiveTransaction
|
|||||||
return new ReactiveMongoTransactionObject(resourceHolder);
|
return new ReactiveMongoTransactionObject(resourceHolder);
|
||||||
}
|
}
|
||||||
|
|
||||||
/*
|
/*
|
||||||
* (non-Javadoc)
|
* (non-Javadoc)
|
||||||
* @see org.springframework.transaction.reactive.AbstractReactiveTransactionManager#isExistingTransaction(java.lang.Object)
|
* @see org.springframework.transaction.reactive.AbstractReactiveTransactionManager#isExistingTransaction(java.lang.Object)
|
||||||
*/
|
*/
|
||||||
@@ -132,7 +132,7 @@ public class ReactiveMongoTransactionManager extends AbstractReactiveTransaction
|
|||||||
return extractMongoTransaction(transaction).hasResourceHolder();
|
return extractMongoTransaction(transaction).hasResourceHolder();
|
||||||
}
|
}
|
||||||
|
|
||||||
/*
|
/*
|
||||||
* (non-Javadoc)
|
* (non-Javadoc)
|
||||||
* @see org.springframework.transaction.reactive.AbstractReactiveTransactionManager#doBegin(org.springframework.transaction.reactive.TransactionSynchronizationManager, java.lang.Object, org.springframework.transaction.TransactionDefinition)
|
* @see org.springframework.transaction.reactive.AbstractReactiveTransactionManager#doBegin(org.springframework.transaction.reactive.TransactionSynchronizationManager, java.lang.Object, org.springframework.transaction.TransactionDefinition)
|
||||||
*/
|
*/
|
||||||
@@ -175,7 +175,7 @@ public class ReactiveMongoTransactionManager extends AbstractReactiveTransaction
|
|||||||
});
|
});
|
||||||
}
|
}
|
||||||
|
|
||||||
/*
|
/*
|
||||||
* (non-Javadoc)
|
* (non-Javadoc)
|
||||||
* @see org.springframework.transaction.reactive.AbstractReactiveTransactionManager#doSuspend(org.springframework.transaction.reactive.TransactionSynchronizationManager, java.lang.Object)
|
* @see org.springframework.transaction.reactive.AbstractReactiveTransactionManager#doSuspend(org.springframework.transaction.reactive.TransactionSynchronizationManager, java.lang.Object)
|
||||||
*/
|
*/
|
||||||
@@ -192,7 +192,7 @@ public class ReactiveMongoTransactionManager extends AbstractReactiveTransaction
|
|||||||
});
|
});
|
||||||
}
|
}
|
||||||
|
|
||||||
/*
|
/*
|
||||||
* (non-Javadoc)
|
* (non-Javadoc)
|
||||||
* @see org.springframework.transaction.reactive.AbstractReactiveTransactionManager#doResume(org.springframework.transaction.reactive.TransactionSynchronizationManager, java.lang.Object, java.lang.Object)
|
* @see org.springframework.transaction.reactive.AbstractReactiveTransactionManager#doResume(org.springframework.transaction.reactive.TransactionSynchronizationManager, java.lang.Object, java.lang.Object)
|
||||||
*/
|
*/
|
||||||
@@ -203,7 +203,7 @@ public class ReactiveMongoTransactionManager extends AbstractReactiveTransaction
|
|||||||
.fromRunnable(() -> synchronizationManager.bindResource(getRequiredDatabaseFactory(), suspendedResources));
|
.fromRunnable(() -> synchronizationManager.bindResource(getRequiredDatabaseFactory(), suspendedResources));
|
||||||
}
|
}
|
||||||
|
|
||||||
/*
|
/*
|
||||||
* (non-Javadoc)
|
* (non-Javadoc)
|
||||||
* @see org.springframework.transaction.reactive.AbstractReactiveTransactionManager#doCommit(org.springframework.transaction.reactive.TransactionSynchronizationManager, org.springframework.transaction.reactive.GenericReactiveTransaction)
|
* @see org.springframework.transaction.reactive.AbstractReactiveTransactionManager#doCommit(org.springframework.transaction.reactive.TransactionSynchronizationManager, org.springframework.transaction.reactive.GenericReactiveTransaction)
|
||||||
*/
|
*/
|
||||||
@@ -243,7 +243,7 @@ public class ReactiveMongoTransactionManager extends AbstractReactiveTransaction
|
|||||||
return transactionObject.commitTransaction();
|
return transactionObject.commitTransaction();
|
||||||
}
|
}
|
||||||
|
|
||||||
/*
|
/*
|
||||||
* (non-Javadoc)
|
* (non-Javadoc)
|
||||||
* @see org.springframework.transaction.reactive.AbstractReactiveTransactionManager#doRollback(org.springframework.transaction.reactive.TransactionSynchronizationManager, org.springframework.transaction.reactive.GenericReactiveTransaction)
|
* @see org.springframework.transaction.reactive.AbstractReactiveTransactionManager#doRollback(org.springframework.transaction.reactive.TransactionSynchronizationManager, org.springframework.transaction.reactive.GenericReactiveTransaction)
|
||||||
*/
|
*/
|
||||||
@@ -268,7 +268,7 @@ public class ReactiveMongoTransactionManager extends AbstractReactiveTransaction
|
|||||||
});
|
});
|
||||||
}
|
}
|
||||||
|
|
||||||
/*
|
/*
|
||||||
* (non-Javadoc)
|
* (non-Javadoc)
|
||||||
* @see org.springframework.transaction.reactive.AbstractReactiveTransactionManager#doSetRollbackOnly(org.springframework.transaction.reactive.TransactionSynchronizationManager, org.springframework.transaction.reactive.GenericReactiveTransaction)
|
* @see org.springframework.transaction.reactive.AbstractReactiveTransactionManager#doSetRollbackOnly(org.springframework.transaction.reactive.TransactionSynchronizationManager, org.springframework.transaction.reactive.GenericReactiveTransaction)
|
||||||
*/
|
*/
|
||||||
@@ -282,7 +282,7 @@ public class ReactiveMongoTransactionManager extends AbstractReactiveTransaction
|
|||||||
});
|
});
|
||||||
}
|
}
|
||||||
|
|
||||||
/*
|
/*
|
||||||
* (non-Javadoc)
|
* (non-Javadoc)
|
||||||
* @see org.springframework.transaction.reactive.AbstractReactiveTransactionManager#doCleanupAfterCompletion(org.springframework.transaction.reactive.TransactionSynchronizationManager, java.lang.Object)
|
* @see org.springframework.transaction.reactive.AbstractReactiveTransactionManager#doCleanupAfterCompletion(org.springframework.transaction.reactive.TransactionSynchronizationManager, java.lang.Object)
|
||||||
*/
|
*/
|
||||||
@@ -509,7 +509,7 @@ public class ReactiveMongoTransactionManager extends AbstractReactiveTransaction
|
|||||||
return session;
|
return session;
|
||||||
}
|
}
|
||||||
|
|
||||||
/*
|
/*
|
||||||
* (non-Javadoc)
|
* (non-Javadoc)
|
||||||
* @see org.springframework.transaction.support.SmartTransactionObject#isRollbackOnly()
|
* @see org.springframework.transaction.support.SmartTransactionObject#isRollbackOnly()
|
||||||
*/
|
*/
|
||||||
@@ -518,7 +518,7 @@ public class ReactiveMongoTransactionManager extends AbstractReactiveTransaction
|
|||||||
return this.resourceHolder != null && this.resourceHolder.isRollbackOnly();
|
return this.resourceHolder != null && this.resourceHolder.isRollbackOnly();
|
||||||
}
|
}
|
||||||
|
|
||||||
/*
|
/*
|
||||||
* (non-Javadoc)
|
* (non-Javadoc)
|
||||||
* @see org.springframework.transaction.support.SmartTransactionObject#flush()
|
* @see org.springframework.transaction.support.SmartTransactionObject#flush()
|
||||||
*/
|
*/
|
||||||
|
|||||||
@@ -1,5 +1,5 @@
|
|||||||
/*
|
/*
|
||||||
* Copyright 2018-2020 the original author or authors.
|
* Copyright 2018-2021 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-2020 the original author or authors.
|
* Copyright 2018-2021 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 the original author or authors.
|
* Copyright 2020-2021 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-2020 the original author or authors.
|
* Copyright 2010-2021 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-2020 the original author or authors.
|
* Copyright 2018-2021 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-2020 the original author or authors.
|
* Copyright 2016-2021 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-2020 the original author or authors.
|
* Copyright 2011-2021 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 the original author or authors.
|
* Copyright 2019-2021 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-2020 the original author or authors.
|
* Copyright 2013-2021 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.
|
||||||
@@ -61,8 +61,8 @@ public @interface EnableMongoAuditing {
|
|||||||
boolean modifyOnCreate() default true;
|
boolean modifyOnCreate() default true;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Configures a {@link DateTimeProvider} bean name that allows customizing the {@link org.joda.time.DateTime} to be
|
* Configures a {@link DateTimeProvider} bean name that allows customizing the timestamp to be used for setting
|
||||||
* used for setting creation and modification dates.
|
* creation and modification dates.
|
||||||
*
|
*
|
||||||
* @return empty {@link String} by default.
|
* @return empty {@link String} by default.
|
||||||
*/
|
*/
|
||||||
|
|||||||
@@ -0,0 +1,70 @@
|
|||||||
|
/*
|
||||||
|
* Copyright 2020-2021 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.config;
|
||||||
|
|
||||||
|
import java.lang.annotation.Documented;
|
||||||
|
import java.lang.annotation.ElementType;
|
||||||
|
import java.lang.annotation.Inherited;
|
||||||
|
import java.lang.annotation.Retention;
|
||||||
|
import java.lang.annotation.RetentionPolicy;
|
||||||
|
import java.lang.annotation.Target;
|
||||||
|
|
||||||
|
import org.springframework.context.annotation.Import;
|
||||||
|
import org.springframework.data.auditing.DateTimeProvider;
|
||||||
|
import org.springframework.data.domain.ReactiveAuditorAware;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Annotation to enable auditing in MongoDB using reactive infrastructure via annotation configuration.
|
||||||
|
*
|
||||||
|
* @author Mark Paluch
|
||||||
|
* @since 3.1
|
||||||
|
*/
|
||||||
|
@Inherited
|
||||||
|
@Documented
|
||||||
|
@Target(ElementType.TYPE)
|
||||||
|
@Retention(RetentionPolicy.RUNTIME)
|
||||||
|
@Import(ReactiveMongoAuditingRegistrar.class)
|
||||||
|
public @interface EnableReactiveMongoAuditing {
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Configures the {@link ReactiveAuditorAware} bean to be used to lookup the current principal.
|
||||||
|
*
|
||||||
|
* @return empty {@link String} by default.
|
||||||
|
*/
|
||||||
|
String auditorAwareRef() default "";
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Configures whether the creation and modification dates are set. Defaults to {@literal true}.
|
||||||
|
*
|
||||||
|
* @return {@literal true} by default.
|
||||||
|
*/
|
||||||
|
boolean setDates() default true;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Configures whether the entity shall be marked as modified on creation. Defaults to {@literal true}.
|
||||||
|
*
|
||||||
|
* @return {@literal true} by default.
|
||||||
|
*/
|
||||||
|
boolean modifyOnCreate() default true;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Configures a {@link DateTimeProvider} bean name that allows customizing the timestamp to be used for setting
|
||||||
|
* creation and modification dates.
|
||||||
|
*
|
||||||
|
* @return empty {@link String} by default.
|
||||||
|
*/
|
||||||
|
String dateTimeProviderRef() default "";
|
||||||
|
}
|
||||||
@@ -1,5 +1,5 @@
|
|||||||
/*
|
/*
|
||||||
* Copyright 2015-2020 the original author or authors.
|
* Copyright 2015-2021 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-2020 the original author or authors.
|
* Copyright 2013-2021 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-2020 the original author or authors.
|
* Copyright 2011-2021 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-2020 the original author or authors.
|
* Copyright 2012-2021 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-2020 the original author or authors.
|
* Copyright 2013-2021 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,7 +17,6 @@ package org.springframework.data.mongodb.config;
|
|||||||
|
|
||||||
import java.lang.annotation.Annotation;
|
import java.lang.annotation.Annotation;
|
||||||
|
|
||||||
import org.springframework.beans.factory.FactoryBean;
|
|
||||||
import org.springframework.beans.factory.config.BeanDefinition;
|
import org.springframework.beans.factory.config.BeanDefinition;
|
||||||
import org.springframework.beans.factory.support.AbstractBeanDefinition;
|
import org.springframework.beans.factory.support.AbstractBeanDefinition;
|
||||||
import org.springframework.beans.factory.support.BeanDefinitionBuilder;
|
import org.springframework.beans.factory.support.BeanDefinitionBuilder;
|
||||||
@@ -28,14 +27,8 @@ import org.springframework.data.auditing.IsNewAwareAuditingHandler;
|
|||||||
import org.springframework.data.auditing.config.AuditingBeanDefinitionRegistrarSupport;
|
import org.springframework.data.auditing.config.AuditingBeanDefinitionRegistrarSupport;
|
||||||
import org.springframework.data.auditing.config.AuditingConfiguration;
|
import org.springframework.data.auditing.config.AuditingConfiguration;
|
||||||
import org.springframework.data.config.ParsingUtils;
|
import org.springframework.data.config.ParsingUtils;
|
||||||
import org.springframework.data.mapping.context.MappingContext;
|
|
||||||
import org.springframework.data.mongodb.core.convert.MappingMongoConverter;
|
|
||||||
import org.springframework.data.mongodb.core.mapping.MongoPersistentEntity;
|
|
||||||
import org.springframework.data.mongodb.core.mapping.MongoPersistentProperty;
|
|
||||||
import org.springframework.data.mongodb.core.mapping.event.AuditingEntityCallback;
|
import org.springframework.data.mongodb.core.mapping.event.AuditingEntityCallback;
|
||||||
import org.springframework.data.mongodb.core.mapping.event.ReactiveAuditingEntityCallback;
|
|
||||||
import org.springframework.util.Assert;
|
import org.springframework.util.Assert;
|
||||||
import org.springframework.util.ClassUtils;
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* {@link ImportBeanDefinitionRegistrar} to enable {@link EnableMongoAuditing} annotation.
|
* {@link ImportBeanDefinitionRegistrar} to enable {@link EnableMongoAuditing} annotation.
|
||||||
@@ -46,9 +39,6 @@ import org.springframework.util.ClassUtils;
|
|||||||
*/
|
*/
|
||||||
class MongoAuditingRegistrar extends AuditingBeanDefinitionRegistrarSupport {
|
class MongoAuditingRegistrar extends AuditingBeanDefinitionRegistrarSupport {
|
||||||
|
|
||||||
private static boolean PROJECT_REACTOR_AVAILABLE = ClassUtils.isPresent("reactor.core.publisher.Mono",
|
|
||||||
MongoAuditingRegistrar.class.getClassLoader());
|
|
||||||
|
|
||||||
/*
|
/*
|
||||||
* (non-Javadoc)
|
* (non-Javadoc)
|
||||||
* @see org.springframework.data.auditing.config.AuditingBeanDefinitionRegistrarSupport#getAnnotation()
|
* @see org.springframework.data.auditing.config.AuditingBeanDefinitionRegistrarSupport#getAnnotation()
|
||||||
@@ -91,7 +81,7 @@ class MongoAuditingRegistrar extends AuditingBeanDefinitionRegistrarSupport {
|
|||||||
|
|
||||||
BeanDefinitionBuilder builder = BeanDefinitionBuilder.rootBeanDefinition(IsNewAwareAuditingHandler.class);
|
BeanDefinitionBuilder builder = BeanDefinitionBuilder.rootBeanDefinition(IsNewAwareAuditingHandler.class);
|
||||||
|
|
||||||
BeanDefinitionBuilder definition = BeanDefinitionBuilder.genericBeanDefinition(MongoMappingContextLookup.class);
|
BeanDefinitionBuilder definition = BeanDefinitionBuilder.genericBeanDefinition(PersistentEntitiesFactoryBean.class);
|
||||||
definition.setAutowireMode(AbstractBeanDefinition.AUTOWIRE_CONSTRUCTOR);
|
definition.setAutowireMode(AbstractBeanDefinition.AUTOWIRE_CONSTRUCTOR);
|
||||||
|
|
||||||
builder.addConstructorArgValue(definition.getBeanDefinition());
|
builder.addConstructorArgValue(definition.getBeanDefinition());
|
||||||
@@ -116,68 +106,6 @@ class MongoAuditingRegistrar extends AuditingBeanDefinitionRegistrarSupport {
|
|||||||
|
|
||||||
registerInfrastructureBeanWithId(listenerBeanDefinitionBuilder.getBeanDefinition(),
|
registerInfrastructureBeanWithId(listenerBeanDefinitionBuilder.getBeanDefinition(),
|
||||||
AuditingEntityCallback.class.getName(), registry);
|
AuditingEntityCallback.class.getName(), registry);
|
||||||
|
|
||||||
if (PROJECT_REACTOR_AVAILABLE) {
|
|
||||||
registerReactiveAuditingEntityCallback(registry, auditingHandlerDefinition.getSource());
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
|
||||||
private void registerReactiveAuditingEntityCallback(BeanDefinitionRegistry registry, Object source) {
|
|
||||||
|
|
||||||
BeanDefinitionBuilder builder = BeanDefinitionBuilder.rootBeanDefinition(ReactiveAuditingEntityCallback.class);
|
|
||||||
|
|
||||||
builder.addConstructorArgValue(ParsingUtils.getObjectFactoryBeanDefinition(getAuditingHandlerBeanName(), registry));
|
|
||||||
builder.getRawBeanDefinition().setSource(source);
|
|
||||||
|
|
||||||
registerInfrastructureBeanWithId(builder.getBeanDefinition(), ReactiveAuditingEntityCallback.class.getName(),
|
|
||||||
registry);
|
|
||||||
}
|
|
||||||
|
|
||||||
/**
|
|
||||||
* Simple helper to be able to wire the {@link MappingContext} from a {@link MappingMongoConverter} bean available in
|
|
||||||
* the application context.
|
|
||||||
*
|
|
||||||
* @author Oliver Gierke
|
|
||||||
*/
|
|
||||||
static class MongoMappingContextLookup
|
|
||||||
implements FactoryBean<MappingContext<? extends MongoPersistentEntity<?>, MongoPersistentProperty>> {
|
|
||||||
|
|
||||||
private final MappingMongoConverter converter;
|
|
||||||
|
|
||||||
/**
|
|
||||||
* Creates a new {@link MongoMappingContextLookup} for the given {@link MappingMongoConverter}.
|
|
||||||
*
|
|
||||||
* @param converter must not be {@literal null}.
|
|
||||||
*/
|
|
||||||
public MongoMappingContextLookup(MappingMongoConverter converter) {
|
|
||||||
this.converter = converter;
|
|
||||||
}
|
|
||||||
|
|
||||||
/*
|
|
||||||
* (non-Javadoc)
|
|
||||||
* @see org.springframework.beans.factory.FactoryBean#getObject()
|
|
||||||
*/
|
|
||||||
@Override
|
|
||||||
public MappingContext<? extends MongoPersistentEntity<?>, MongoPersistentProperty> getObject() throws Exception {
|
|
||||||
return converter.getMappingContext();
|
|
||||||
}
|
|
||||||
|
|
||||||
/*
|
|
||||||
* (non-Javadoc)
|
|
||||||
* @see org.springframework.beans.factory.FactoryBean#getObjectType()
|
|
||||||
*/
|
|
||||||
@Override
|
|
||||||
public Class<?> getObjectType() {
|
|
||||||
return MappingContext.class;
|
|
||||||
}
|
|
||||||
|
|
||||||
/*
|
|
||||||
* (non-Javadoc)
|
|
||||||
* @see org.springframework.beans.factory.FactoryBean#isSingleton()
|
|
||||||
*/
|
|
||||||
@Override
|
|
||||||
public boolean isSingleton() {
|
|
||||||
return true;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -1,5 +1,5 @@
|
|||||||
/*
|
/*
|
||||||
* Copyright 2015-2020 the original author or authors.
|
* Copyright 2015-2021 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-2020 the original author or authors.
|
* Copyright 2016-2021 the original author or authors.
|
||||||
*
|
*
|
||||||
* Licensed under the Apache License, Version 2.0 (the "License");
|
* Licensed under the Apache License, Version 2.0 (the "License");
|
||||||
* you may not use this file except in compliance with the License.
|
* you may not use this file except in compliance with the License.
|
||||||
@@ -26,7 +26,6 @@ import org.springframework.context.annotation.Bean;
|
|||||||
import org.springframework.context.annotation.ClassPathScanningCandidateComponentProvider;
|
import org.springframework.context.annotation.ClassPathScanningCandidateComponentProvider;
|
||||||
import org.springframework.core.convert.converter.Converter;
|
import org.springframework.core.convert.converter.Converter;
|
||||||
import org.springframework.core.type.filter.AnnotationTypeFilter;
|
import org.springframework.core.type.filter.AnnotationTypeFilter;
|
||||||
import org.springframework.data.annotation.Persistent;
|
|
||||||
import org.springframework.data.convert.CustomConversions;
|
import org.springframework.data.convert.CustomConversions;
|
||||||
import org.springframework.data.mapping.model.CamelCaseAbbreviatingFieldNamingStrategy;
|
import org.springframework.data.mapping.model.CamelCaseAbbreviatingFieldNamingStrategy;
|
||||||
import org.springframework.data.mapping.model.FieldNamingStrategy;
|
import org.springframework.data.mapping.model.FieldNamingStrategy;
|
||||||
@@ -140,8 +139,7 @@ public abstract class MongoConfigurationSupport {
|
|||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Scans the given base package for entities, i.e. MongoDB specific types annotated with {@link Document} and
|
* Scans the given base package for entities, i.e. MongoDB specific types annotated with {@link Document}.
|
||||||
* {@link Persistent}.
|
|
||||||
*
|
*
|
||||||
* @param basePackage must not be {@literal null}.
|
* @param basePackage must not be {@literal null}.
|
||||||
* @return
|
* @return
|
||||||
@@ -161,7 +159,6 @@ public abstract class MongoConfigurationSupport {
|
|||||||
ClassPathScanningCandidateComponentProvider componentProvider = new ClassPathScanningCandidateComponentProvider(
|
ClassPathScanningCandidateComponentProvider componentProvider = new ClassPathScanningCandidateComponentProvider(
|
||||||
false);
|
false);
|
||||||
componentProvider.addIncludeFilter(new AnnotationTypeFilter(Document.class));
|
componentProvider.addIncludeFilter(new AnnotationTypeFilter(Document.class));
|
||||||
componentProvider.addIncludeFilter(new AnnotationTypeFilter(Persistent.class));
|
|
||||||
|
|
||||||
for (BeanDefinition candidate : componentProvider.findCandidateComponents(basePackage)) {
|
for (BeanDefinition candidate : componentProvider.findCandidateComponents(basePackage)) {
|
||||||
|
|
||||||
|
|||||||
@@ -1,5 +1,5 @@
|
|||||||
/*
|
/*
|
||||||
* Copyright 2015-2020 the original author or authors.
|
* Copyright 2015-2021 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-2020 the original author or authors.
|
* Copyright 2011-2021 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-2020 the original author or authors.
|
* Copyright 2011-2021 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-2020 the original author or authors.
|
* Copyright 2011-2021 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-2020 the original author or authors.
|
* Copyright 2011-2021 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.
|
||||||
@@ -45,7 +45,7 @@ abstract class MongoParsingUtils {
|
|||||||
/**
|
/**
|
||||||
* Parses the {@code mongo:client-settings} sub-element. Populates the given attribute factory with the proper
|
* Parses the {@code mongo:client-settings} sub-element. Populates the given attribute factory with the proper
|
||||||
* attributes.
|
* attributes.
|
||||||
*
|
*
|
||||||
* @param element
|
* @param element
|
||||||
* @param mongoClientBuilder
|
* @param mongoClientBuilder
|
||||||
* @return
|
* @return
|
||||||
|
|||||||
@@ -1,5 +1,5 @@
|
|||||||
/*
|
/*
|
||||||
* Copyright 2011-2020 the original author or authors.
|
* Copyright 2011-2021 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,61 @@
|
|||||||
|
/*
|
||||||
|
* Copyright 2020-2021 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.config;
|
||||||
|
|
||||||
|
import org.springframework.beans.factory.FactoryBean;
|
||||||
|
import org.springframework.data.mapping.context.PersistentEntities;
|
||||||
|
import org.springframework.data.mongodb.core.convert.MappingMongoConverter;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Simple helper to be able to wire the {@link PersistentEntities} from a {@link MappingMongoConverter} bean available
|
||||||
|
* in the application context.
|
||||||
|
*
|
||||||
|
* @author Oliver Gierke
|
||||||
|
* @author Mark Paluch
|
||||||
|
* @author Christoph Strobl
|
||||||
|
* @since 3.1
|
||||||
|
*/
|
||||||
|
class PersistentEntitiesFactoryBean implements FactoryBean<PersistentEntities> {
|
||||||
|
|
||||||
|
private final MappingMongoConverter converter;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Creates a new {@link PersistentEntitiesFactoryBean} for the given {@link MappingMongoConverter}.
|
||||||
|
*
|
||||||
|
* @param converter must not be {@literal null}.
|
||||||
|
*/
|
||||||
|
public PersistentEntitiesFactoryBean(MappingMongoConverter converter) {
|
||||||
|
this.converter = converter;
|
||||||
|
}
|
||||||
|
|
||||||
|
/*
|
||||||
|
* (non-Javadoc)
|
||||||
|
* @see org.springframework.beans.factory.FactoryBean#getObject()
|
||||||
|
*/
|
||||||
|
@Override
|
||||||
|
public PersistentEntities getObject() {
|
||||||
|
return PersistentEntities.of(converter.getMappingContext());
|
||||||
|
}
|
||||||
|
|
||||||
|
/*
|
||||||
|
* (non-Javadoc)
|
||||||
|
* @see org.springframework.beans.factory.FactoryBean#getObjectType()
|
||||||
|
*/
|
||||||
|
@Override
|
||||||
|
public Class<?> getObjectType() {
|
||||||
|
return PersistentEntities.class;
|
||||||
|
}
|
||||||
|
}
|
||||||
@@ -0,0 +1,97 @@
|
|||||||
|
/*
|
||||||
|
* Copyright 2020-2021 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.config;
|
||||||
|
|
||||||
|
import java.lang.annotation.Annotation;
|
||||||
|
|
||||||
|
import org.springframework.beans.factory.config.BeanDefinition;
|
||||||
|
import org.springframework.beans.factory.support.AbstractBeanDefinition;
|
||||||
|
import org.springframework.beans.factory.support.BeanDefinitionBuilder;
|
||||||
|
import org.springframework.beans.factory.support.BeanDefinitionRegistry;
|
||||||
|
import org.springframework.context.annotation.ImportBeanDefinitionRegistrar;
|
||||||
|
import org.springframework.core.type.AnnotationMetadata;
|
||||||
|
import org.springframework.data.auditing.ReactiveIsNewAwareAuditingHandler;
|
||||||
|
import org.springframework.data.auditing.config.AuditingBeanDefinitionRegistrarSupport;
|
||||||
|
import org.springframework.data.auditing.config.AuditingConfiguration;
|
||||||
|
import org.springframework.data.config.ParsingUtils;
|
||||||
|
import org.springframework.data.mongodb.core.mapping.event.ReactiveAuditingEntityCallback;
|
||||||
|
import org.springframework.util.Assert;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* {@link ImportBeanDefinitionRegistrar} to enable {@link EnableReactiveMongoAuditing} annotation.
|
||||||
|
*
|
||||||
|
* @author Mark Paluch
|
||||||
|
* @since 3.1
|
||||||
|
*/
|
||||||
|
class ReactiveMongoAuditingRegistrar extends AuditingBeanDefinitionRegistrarSupport {
|
||||||
|
|
||||||
|
/*
|
||||||
|
* (non-Javadoc)
|
||||||
|
* @see org.springframework.data.auditing.config.AuditingBeanDefinitionRegistrarSupport#getAnnotation()
|
||||||
|
*/
|
||||||
|
@Override
|
||||||
|
protected Class<? extends Annotation> getAnnotation() {
|
||||||
|
return EnableReactiveMongoAuditing.class;
|
||||||
|
}
|
||||||
|
|
||||||
|
/*
|
||||||
|
* (non-Javadoc)
|
||||||
|
* @see org.springframework.data.auditing.config.AuditingBeanDefinitionRegistrarSupport#getAuditingHandlerBeanName()
|
||||||
|
*/
|
||||||
|
@Override
|
||||||
|
protected String getAuditingHandlerBeanName() {
|
||||||
|
return "reactiveMongoAuditingHandler";
|
||||||
|
}
|
||||||
|
|
||||||
|
/*
|
||||||
|
* (non-Javadoc)
|
||||||
|
* @see org.springframework.data.auditing.config.AuditingBeanDefinitionRegistrarSupport#getAuditHandlerBeanDefinitionBuilder(org.springframework.data.auditing.config.AuditingConfiguration)
|
||||||
|
*/
|
||||||
|
@Override
|
||||||
|
protected BeanDefinitionBuilder getAuditHandlerBeanDefinitionBuilder(AuditingConfiguration configuration) {
|
||||||
|
|
||||||
|
Assert.notNull(configuration, "AuditingConfiguration must not be null!");
|
||||||
|
|
||||||
|
BeanDefinitionBuilder builder = BeanDefinitionBuilder.rootBeanDefinition(ReactiveIsNewAwareAuditingHandler.class);
|
||||||
|
|
||||||
|
BeanDefinitionBuilder definition = BeanDefinitionBuilder.genericBeanDefinition(PersistentEntitiesFactoryBean.class);
|
||||||
|
definition.setAutowireMode(AbstractBeanDefinition.AUTOWIRE_CONSTRUCTOR);
|
||||||
|
|
||||||
|
builder.addConstructorArgValue(definition.getBeanDefinition());
|
||||||
|
return configureDefaultAuditHandlerAttributes(configuration, builder);
|
||||||
|
}
|
||||||
|
|
||||||
|
/*
|
||||||
|
* (non-Javadoc)
|
||||||
|
* @see org.springframework.data.auditing.config.AuditingBeanDefinitionRegistrarSupport#registerAuditListener(org.springframework.beans.factory.config.BeanDefinition, org.springframework.beans.factory.support.BeanDefinitionRegistry)
|
||||||
|
*/
|
||||||
|
@Override
|
||||||
|
protected void registerAuditListenerBeanDefinition(BeanDefinition auditingHandlerDefinition,
|
||||||
|
BeanDefinitionRegistry registry) {
|
||||||
|
|
||||||
|
Assert.notNull(auditingHandlerDefinition, "BeanDefinition must not be null!");
|
||||||
|
Assert.notNull(registry, "BeanDefinitionRegistry must not be null!");
|
||||||
|
|
||||||
|
BeanDefinitionBuilder builder = BeanDefinitionBuilder.rootBeanDefinition(ReactiveAuditingEntityCallback.class);
|
||||||
|
|
||||||
|
builder.addConstructorArgValue(ParsingUtils.getObjectFactoryBeanDefinition(getAuditingHandlerBeanName(), registry));
|
||||||
|
builder.getRawBeanDefinition().setSource(auditingHandlerDefinition.getSource());
|
||||||
|
|
||||||
|
registerInfrastructureBeanWithId(builder.getBeanDefinition(), ReactiveAuditingEntityCallback.class.getName(),
|
||||||
|
registry);
|
||||||
|
}
|
||||||
|
|
||||||
|
}
|
||||||
@@ -1,5 +1,5 @@
|
|||||||
/*
|
/*
|
||||||
* Copyright 2019 the original author or authors.
|
* Copyright 2019-2021 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-2020 the original author or authors.
|
* Copyright 2015-2021 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-2020 the original author or authors.
|
* Copyright 2011-2021 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-2020 the original author or authors.
|
* Copyright 2012-2021 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 the original author or authors.
|
* Copyright 2020-2021 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-2020 the original author or authors.
|
* Copyright 2011-2021 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-2020 the original author or authors.
|
* Copyright 2018-2021 the original author or authors.
|
||||||
*
|
*
|
||||||
* Licensed under the Apache License, Version 2.0 (the "License");
|
* Licensed under the Apache License, Version 2.0 (the "License");
|
||||||
* you may not use this file except in compliance with the License.
|
* you may not use this file except in compliance with the License.
|
||||||
@@ -15,8 +15,6 @@
|
|||||||
*/
|
*/
|
||||||
package org.springframework.data.mongodb.core;
|
package org.springframework.data.mongodb.core;
|
||||||
|
|
||||||
import lombok.AllArgsConstructor;
|
|
||||||
|
|
||||||
import java.util.Arrays;
|
import java.util.Arrays;
|
||||||
import java.util.Collections;
|
import java.util.Collections;
|
||||||
import java.util.List;
|
import java.util.List;
|
||||||
@@ -30,6 +28,7 @@ import org.springframework.data.mongodb.core.aggregation.AggregationOperation;
|
|||||||
import org.springframework.data.mongodb.core.aggregation.AggregationOperationContext;
|
import org.springframework.data.mongodb.core.aggregation.AggregationOperationContext;
|
||||||
import org.springframework.data.mongodb.core.aggregation.AggregationOptions;
|
import org.springframework.data.mongodb.core.aggregation.AggregationOptions;
|
||||||
import org.springframework.data.mongodb.core.aggregation.CountOperation;
|
import org.springframework.data.mongodb.core.aggregation.CountOperation;
|
||||||
|
import org.springframework.data.mongodb.core.aggregation.RelaxedTypeBasedAggregationOperationContext;
|
||||||
import org.springframework.data.mongodb.core.aggregation.TypeBasedAggregationOperationContext;
|
import org.springframework.data.mongodb.core.aggregation.TypeBasedAggregationOperationContext;
|
||||||
import org.springframework.data.mongodb.core.aggregation.TypedAggregation;
|
import org.springframework.data.mongodb.core.aggregation.TypedAggregation;
|
||||||
import org.springframework.data.mongodb.core.convert.QueryMapper;
|
import org.springframework.data.mongodb.core.convert.QueryMapper;
|
||||||
@@ -49,12 +48,18 @@ import org.springframework.util.ObjectUtils;
|
|||||||
* @author Mark Paluch
|
* @author Mark Paluch
|
||||||
* @since 2.1
|
* @since 2.1
|
||||||
*/
|
*/
|
||||||
@AllArgsConstructor
|
|
||||||
class AggregationUtil {
|
class AggregationUtil {
|
||||||
|
|
||||||
QueryMapper queryMapper;
|
QueryMapper queryMapper;
|
||||||
MappingContext<? extends MongoPersistentEntity<?>, MongoPersistentProperty> mappingContext;
|
MappingContext<? extends MongoPersistentEntity<?>, MongoPersistentProperty> mappingContext;
|
||||||
|
|
||||||
|
AggregationUtil(QueryMapper queryMapper,
|
||||||
|
MappingContext<? extends MongoPersistentEntity<?>, MongoPersistentProperty> mappingContext) {
|
||||||
|
|
||||||
|
this.queryMapper = queryMapper;
|
||||||
|
this.mappingContext = mappingContext;
|
||||||
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Prepare the {@link AggregationOperationContext} for a given aggregation by either returning the context itself it
|
* Prepare the {@link AggregationOperationContext} for a given aggregation by either returning the context itself it
|
||||||
* is not {@literal null}, create a {@link TypeBasedAggregationOperationContext} if the aggregation contains type
|
* is not {@literal null}, create a {@link TypeBasedAggregationOperationContext} if the aggregation contains type
|
||||||
@@ -71,12 +76,17 @@ class AggregationUtil {
|
|||||||
return context;
|
return context;
|
||||||
}
|
}
|
||||||
|
|
||||||
if (aggregation instanceof TypedAggregation) {
|
if (!(aggregation instanceof TypedAggregation)) {
|
||||||
return new TypeBasedAggregationOperationContext(((TypedAggregation) aggregation).getInputType(), mappingContext,
|
return new RelaxedTypeBasedAggregationOperationContext(Object.class, mappingContext, queryMapper);
|
||||||
queryMapper);
|
|
||||||
}
|
}
|
||||||
|
|
||||||
return Aggregation.DEFAULT_CONTEXT;
|
Class<?> inputType = ((TypedAggregation) aggregation).getInputType();
|
||||||
|
|
||||||
|
if (aggregation.getPipeline().containsUnionWith()) {
|
||||||
|
return new RelaxedTypeBasedAggregationOperationContext(inputType, mappingContext, queryMapper);
|
||||||
|
}
|
||||||
|
|
||||||
|
return new TypeBasedAggregationOperationContext(inputType, mappingContext, queryMapper);
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
@@ -88,7 +98,7 @@ class AggregationUtil {
|
|||||||
*/
|
*/
|
||||||
List<Document> createPipeline(Aggregation aggregation, AggregationOperationContext context) {
|
List<Document> createPipeline(Aggregation aggregation, AggregationOperationContext context) {
|
||||||
|
|
||||||
if (!ObjectUtils.nullSafeEquals(context, Aggregation.DEFAULT_CONTEXT)) {
|
if (ObjectUtils.nullSafeEquals(context, Aggregation.DEFAULT_CONTEXT)) {
|
||||||
return aggregation.toPipeline(context);
|
return aggregation.toPipeline(context);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
@@ -1,5 +1,5 @@
|
|||||||
/*
|
/*
|
||||||
* Copyright 2015-2020 the original author or authors.
|
* Copyright 2015-2021 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-2020 the original author or authors.
|
* Copyright 2018-2021 the original author or authors.
|
||||||
*
|
*
|
||||||
* Licensed under the Apache License, Version 2.0 (the "License");
|
* Licensed under the Apache License, Version 2.0 (the "License");
|
||||||
* you may not use this file except in compliance with the License.
|
* you may not use this file except in compliance with the License.
|
||||||
@@ -15,8 +15,6 @@
|
|||||||
*/
|
*/
|
||||||
package org.springframework.data.mongodb.core;
|
package org.springframework.data.mongodb.core;
|
||||||
|
|
||||||
import lombok.EqualsAndHashCode;
|
|
||||||
|
|
||||||
import java.time.Instant;
|
import java.time.Instant;
|
||||||
import java.util.concurrent.atomic.AtomicReferenceFieldUpdater;
|
import java.util.concurrent.atomic.AtomicReferenceFieldUpdater;
|
||||||
|
|
||||||
@@ -27,6 +25,7 @@ import org.springframework.data.mongodb.core.convert.MongoConverter;
|
|||||||
import org.springframework.data.mongodb.core.messaging.Message;
|
import org.springframework.data.mongodb.core.messaging.Message;
|
||||||
import org.springframework.lang.Nullable;
|
import org.springframework.lang.Nullable;
|
||||||
import org.springframework.util.ClassUtils;
|
import org.springframework.util.ClassUtils;
|
||||||
|
import org.springframework.util.ObjectUtils;
|
||||||
|
|
||||||
import com.mongodb.client.model.changestream.ChangeStreamDocument;
|
import com.mongodb.client.model.changestream.ChangeStreamDocument;
|
||||||
import com.mongodb.client.model.changestream.OperationType;
|
import com.mongodb.client.model.changestream.OperationType;
|
||||||
@@ -39,7 +38,6 @@ import com.mongodb.client.model.changestream.OperationType;
|
|||||||
* @author Mark Paluch
|
* @author Mark Paluch
|
||||||
* @since 2.1
|
* @since 2.1
|
||||||
*/
|
*/
|
||||||
@EqualsAndHashCode
|
|
||||||
public class ChangeStreamEvent<T> {
|
public class ChangeStreamEvent<T> {
|
||||||
|
|
||||||
@SuppressWarnings("rawtypes") //
|
@SuppressWarnings("rawtypes") //
|
||||||
@@ -187,8 +185,8 @@ public class ChangeStreamEvent<T> {
|
|||||||
return CONVERTED_UPDATER.compareAndSet(this, null, result) ? result : CONVERTED_UPDATER.get(this);
|
return CONVERTED_UPDATER.compareAndSet(this, null, result) ? result : CONVERTED_UPDATER.get(this);
|
||||||
}
|
}
|
||||||
|
|
||||||
throw new IllegalArgumentException(String.format("No converter found capable of converting %s to %s",
|
throw new IllegalArgumentException(
|
||||||
fullDocument.getClass(), targetType));
|
String.format("No converter found capable of converting %s to %s", fullDocument.getClass(), targetType));
|
||||||
}
|
}
|
||||||
|
|
||||||
/*
|
/*
|
||||||
@@ -199,4 +197,27 @@ public class ChangeStreamEvent<T> {
|
|||||||
public String toString() {
|
public String toString() {
|
||||||
return "ChangeStreamEvent {" + "raw=" + raw + ", targetType=" + targetType + '}';
|
return "ChangeStreamEvent {" + "raw=" + raw + ", targetType=" + targetType + '}';
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public boolean equals(Object o) {
|
||||||
|
|
||||||
|
if (this == o)
|
||||||
|
return true;
|
||||||
|
if (o == null || getClass() != o.getClass())
|
||||||
|
return false;
|
||||||
|
|
||||||
|
ChangeStreamEvent<?> that = (ChangeStreamEvent<?>) o;
|
||||||
|
|
||||||
|
if (!ObjectUtils.nullSafeEquals(this.raw, that.raw)) {
|
||||||
|
return false;
|
||||||
|
}
|
||||||
|
return ObjectUtils.nullSafeEquals(this.targetType, that.targetType);
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public int hashCode() {
|
||||||
|
int result = raw != null ? raw.hashCode() : 0;
|
||||||
|
result = 31 * result + ObjectUtils.nullSafeHashCode(targetType);
|
||||||
|
return result;
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -1,5 +1,5 @@
|
|||||||
/*
|
/*
|
||||||
* Copyright 2018-2020 the original author or authors.
|
* Copyright 2018-2021 the original author or authors.
|
||||||
*
|
*
|
||||||
* Licensed under the Apache License, Version 2.0 (the "License");
|
* Licensed under the Apache License, Version 2.0 (the "License");
|
||||||
* you may not use this file except in compliance with the License.
|
* you may not use this file except in compliance with the License.
|
||||||
@@ -15,8 +15,6 @@
|
|||||||
*/
|
*/
|
||||||
package org.springframework.data.mongodb.core;
|
package org.springframework.data.mongodb.core;
|
||||||
|
|
||||||
import lombok.EqualsAndHashCode;
|
|
||||||
|
|
||||||
import java.time.Instant;
|
import java.time.Instant;
|
||||||
import java.util.Arrays;
|
import java.util.Arrays;
|
||||||
import java.util.Optional;
|
import java.util.Optional;
|
||||||
@@ -25,7 +23,6 @@ import org.bson.BsonDocument;
|
|||||||
import org.bson.BsonTimestamp;
|
import org.bson.BsonTimestamp;
|
||||||
import org.bson.BsonValue;
|
import org.bson.BsonValue;
|
||||||
import org.bson.Document;
|
import org.bson.Document;
|
||||||
|
|
||||||
import org.springframework.data.mongodb.core.aggregation.Aggregation;
|
import org.springframework.data.mongodb.core.aggregation.Aggregation;
|
||||||
import org.springframework.data.mongodb.core.query.Collation;
|
import org.springframework.data.mongodb.core.query.Collation;
|
||||||
import org.springframework.lang.Nullable;
|
import org.springframework.lang.Nullable;
|
||||||
@@ -45,7 +42,6 @@ import com.mongodb.client.model.changestream.FullDocument;
|
|||||||
* @author Mark Paluch
|
* @author Mark Paluch
|
||||||
* @since 2.1
|
* @since 2.1
|
||||||
*/
|
*/
|
||||||
@EqualsAndHashCode
|
|
||||||
public class ChangeStreamOptions {
|
public class ChangeStreamOptions {
|
||||||
|
|
||||||
private @Nullable Object filter;
|
private @Nullable Object filter;
|
||||||
@@ -156,6 +152,44 @@ public class ChangeStreamOptions {
|
|||||||
+ ObjectUtils.nullSafeClassName(timestamp));
|
+ ObjectUtils.nullSafeClassName(timestamp));
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public boolean equals(Object o) {
|
||||||
|
if (this == o)
|
||||||
|
return true;
|
||||||
|
if (o == null || getClass() != o.getClass())
|
||||||
|
return false;
|
||||||
|
|
||||||
|
ChangeStreamOptions that = (ChangeStreamOptions) o;
|
||||||
|
|
||||||
|
if (!ObjectUtils.nullSafeEquals(this.filter, that.filter)) {
|
||||||
|
return false;
|
||||||
|
}
|
||||||
|
if (!ObjectUtils.nullSafeEquals(this.resumeToken, that.resumeToken)) {
|
||||||
|
return false;
|
||||||
|
}
|
||||||
|
if (!ObjectUtils.nullSafeEquals(this.fullDocumentLookup, that.fullDocumentLookup)) {
|
||||||
|
return false;
|
||||||
|
}
|
||||||
|
if (!ObjectUtils.nullSafeEquals(this.collation, that.collation)) {
|
||||||
|
return false;
|
||||||
|
}
|
||||||
|
if (!ObjectUtils.nullSafeEquals(this.resumeTimestamp, that.resumeTimestamp)) {
|
||||||
|
return false;
|
||||||
|
}
|
||||||
|
return resume == that.resume;
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public int hashCode() {
|
||||||
|
int result = ObjectUtils.nullSafeHashCode(filter);
|
||||||
|
result = 31 * result + ObjectUtils.nullSafeHashCode(resumeToken);
|
||||||
|
result = 31 * result + ObjectUtils.nullSafeHashCode(fullDocumentLookup);
|
||||||
|
result = 31 * result + ObjectUtils.nullSafeHashCode(collation);
|
||||||
|
result = 31 * result + ObjectUtils.nullSafeHashCode(resumeTimestamp);
|
||||||
|
result = 31 * result + ObjectUtils.nullSafeHashCode(resume);
|
||||||
|
return result;
|
||||||
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* @author Christoph Strobl
|
* @author Christoph Strobl
|
||||||
* @since 2.2
|
* @since 2.2
|
||||||
|
|||||||
@@ -1,5 +1,5 @@
|
|||||||
/*
|
/*
|
||||||
* Copyright 2010-2020 the original author or authors.
|
* Copyright 2010-2021 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-2020 the original author or authors.
|
* Copyright 2010-2021 the original author or authors.
|
||||||
*
|
*
|
||||||
* Licensed under the Apache License, Version 2.0 (the "License");
|
* Licensed under the Apache License, Version 2.0 (the "License");
|
||||||
* you may not use this file except in compliance with the License.
|
* you may not use this file except in compliance with the License.
|
||||||
@@ -15,8 +15,6 @@
|
|||||||
*/
|
*/
|
||||||
package org.springframework.data.mongodb.core;
|
package org.springframework.data.mongodb.core;
|
||||||
|
|
||||||
import lombok.RequiredArgsConstructor;
|
|
||||||
|
|
||||||
import java.util.Optional;
|
import java.util.Optional;
|
||||||
|
|
||||||
import org.springframework.data.mongodb.core.query.Collation;
|
import org.springframework.data.mongodb.core.query.Collation;
|
||||||
@@ -312,7 +310,6 @@ public class CollectionOptions {
|
|||||||
* @author Andreas Zink
|
* @author Andreas Zink
|
||||||
* @since 2.1
|
* @since 2.1
|
||||||
*/
|
*/
|
||||||
@RequiredArgsConstructor
|
|
||||||
public static class ValidationOptions {
|
public static class ValidationOptions {
|
||||||
|
|
||||||
private static final ValidationOptions NONE = new ValidationOptions(null, null, null);
|
private static final ValidationOptions NONE = new ValidationOptions(null, null, null);
|
||||||
@@ -321,6 +318,13 @@ public class CollectionOptions {
|
|||||||
private final @Nullable ValidationLevel validationLevel;
|
private final @Nullable ValidationLevel validationLevel;
|
||||||
private final @Nullable ValidationAction validationAction;
|
private final @Nullable ValidationAction validationAction;
|
||||||
|
|
||||||
|
public ValidationOptions(Validator validator, ValidationLevel validationLevel, ValidationAction validationAction) {
|
||||||
|
|
||||||
|
this.validator = validator;
|
||||||
|
this.validationLevel = validationLevel;
|
||||||
|
this.validationAction = validationAction;
|
||||||
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Create an empty {@link ValidationOptions}.
|
* Create an empty {@link ValidationOptions}.
|
||||||
*
|
*
|
||||||
|
|||||||
@@ -1,5 +1,5 @@
|
|||||||
/*
|
/*
|
||||||
* Copyright 2019-2020 the original author or authors.
|
* Copyright 2019-2021 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 2002-2020 the original author or authors.
|
* Copyright 2002-2021 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-2020 the original author or authors.
|
* Copyright 2010-2021 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-2020 the original author or authors.
|
* Copyright 2015-2021 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,9 +15,6 @@
|
|||||||
*/
|
*/
|
||||||
package org.springframework.data.mongodb.core;
|
package org.springframework.data.mongodb.core;
|
||||||
|
|
||||||
import lombok.NonNull;
|
|
||||||
import lombok.Value;
|
|
||||||
|
|
||||||
import java.util.ArrayList;
|
import java.util.ArrayList;
|
||||||
import java.util.Collections;
|
import java.util.Collections;
|
||||||
import java.util.List;
|
import java.util.List;
|
||||||
@@ -27,8 +24,9 @@ import java.util.stream.Collectors;
|
|||||||
import org.bson.Document;
|
import org.bson.Document;
|
||||||
import org.bson.conversions.Bson;
|
import org.bson.conversions.Bson;
|
||||||
import org.springframework.context.ApplicationEventPublisher;
|
import org.springframework.context.ApplicationEventPublisher;
|
||||||
import org.springframework.dao.support.PersistenceExceptionTranslator;
|
import org.springframework.dao.DataIntegrityViolationException;
|
||||||
import org.springframework.data.mapping.callback.EntityCallbacks;
|
import org.springframework.data.mapping.callback.EntityCallbacks;
|
||||||
|
import org.springframework.data.mongodb.BulkOperationException;
|
||||||
import org.springframework.data.mongodb.core.convert.QueryMapper;
|
import org.springframework.data.mongodb.core.convert.QueryMapper;
|
||||||
import org.springframework.data.mongodb.core.convert.UpdateMapper;
|
import org.springframework.data.mongodb.core.convert.UpdateMapper;
|
||||||
import org.springframework.data.mongodb.core.mapping.MongoPersistentEntity;
|
import org.springframework.data.mongodb.core.mapping.MongoPersistentEntity;
|
||||||
@@ -47,7 +45,9 @@ import org.springframework.data.mongodb.core.query.UpdateDefinition.ArrayFilter;
|
|||||||
import org.springframework.data.util.Pair;
|
import org.springframework.data.util.Pair;
|
||||||
import org.springframework.lang.Nullable;
|
import org.springframework.lang.Nullable;
|
||||||
import org.springframework.util.Assert;
|
import org.springframework.util.Assert;
|
||||||
|
import org.springframework.util.ObjectUtils;
|
||||||
|
|
||||||
|
import com.mongodb.MongoBulkWriteException;
|
||||||
import com.mongodb.WriteConcern;
|
import com.mongodb.WriteConcern;
|
||||||
import com.mongodb.bulk.BulkWriteResult;
|
import com.mongodb.bulk.BulkWriteResult;
|
||||||
import com.mongodb.client.MongoCollection;
|
import com.mongodb.client.MongoCollection;
|
||||||
@@ -64,6 +64,7 @@ import com.mongodb.client.model.*;
|
|||||||
* @author Jens Schauder
|
* @author Jens Schauder
|
||||||
* @author Michail Nikolaev
|
* @author Michail Nikolaev
|
||||||
* @author Roman Puchkovskiy
|
* @author Roman Puchkovskiy
|
||||||
|
* @author Jacob Botuck
|
||||||
* @since 1.9
|
* @since 1.9
|
||||||
*/
|
*/
|
||||||
class DefaultBulkOperations implements BulkOperations {
|
class DefaultBulkOperations implements BulkOperations {
|
||||||
@@ -73,7 +74,6 @@ class DefaultBulkOperations implements BulkOperations {
|
|||||||
private final BulkOperationContext bulkOperationContext;
|
private final BulkOperationContext bulkOperationContext;
|
||||||
private final List<SourceAwareWriteModelHolder> models = new ArrayList<>();
|
private final List<SourceAwareWriteModelHolder> models = new ArrayList<>();
|
||||||
|
|
||||||
private PersistenceExceptionTranslator exceptionTranslator;
|
|
||||||
private @Nullable WriteConcern defaultWriteConcern;
|
private @Nullable WriteConcern defaultWriteConcern;
|
||||||
|
|
||||||
private BulkWriteOptions bulkOptions;
|
private BulkWriteOptions bulkOptions;
|
||||||
@@ -97,19 +97,9 @@ class DefaultBulkOperations implements BulkOperations {
|
|||||||
this.mongoOperations = mongoOperations;
|
this.mongoOperations = mongoOperations;
|
||||||
this.collectionName = collectionName;
|
this.collectionName = collectionName;
|
||||||
this.bulkOperationContext = bulkOperationContext;
|
this.bulkOperationContext = bulkOperationContext;
|
||||||
this.exceptionTranslator = new MongoExceptionTranslator();
|
|
||||||
this.bulkOptions = getBulkWriteOptions(bulkOperationContext.getBulkMode());
|
this.bulkOptions = getBulkWriteOptions(bulkOperationContext.getBulkMode());
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
|
||||||
* Configures the {@link PersistenceExceptionTranslator} to be used. Defaults to {@link MongoExceptionTranslator}.
|
|
||||||
*
|
|
||||||
* @param exceptionTranslator can be {@literal null}.
|
|
||||||
*/
|
|
||||||
public void setExceptionTranslator(@Nullable PersistenceExceptionTranslator exceptionTranslator) {
|
|
||||||
this.exceptionTranslator = exceptionTranslator == null ? new MongoExceptionTranslator() : exceptionTranslator;
|
|
||||||
}
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Configures the default {@link WriteConcern} to be used. Defaults to {@literal null}.
|
* Configures the default {@link WriteConcern} to be used. Defaults to {@literal null}.
|
||||||
*
|
*
|
||||||
@@ -316,11 +306,26 @@ class DefaultBulkOperations implements BulkOperations {
|
|||||||
collection = collection.withWriteConcern(defaultWriteConcern);
|
collection = collection.withWriteConcern(defaultWriteConcern);
|
||||||
}
|
}
|
||||||
|
|
||||||
return collection.bulkWrite( //
|
try {
|
||||||
models.stream() //
|
|
||||||
.map(this::extractAndMapWriteModel) //
|
return collection.bulkWrite( //
|
||||||
.collect(Collectors.toList()), //
|
models.stream() //
|
||||||
bulkOptions);
|
.map(this::extractAndMapWriteModel) //
|
||||||
|
.collect(Collectors.toList()), //
|
||||||
|
bulkOptions);
|
||||||
|
} catch (RuntimeException ex) {
|
||||||
|
|
||||||
|
if (ex instanceof MongoBulkWriteException) {
|
||||||
|
|
||||||
|
MongoBulkWriteException mongoBulkWriteException = (MongoBulkWriteException) ex;
|
||||||
|
if (mongoBulkWriteException.getWriteConcernError() != null) {
|
||||||
|
throw new DataIntegrityViolationException(ex.getMessage(), ex);
|
||||||
|
}
|
||||||
|
throw new BulkOperationException(ex.getMessage(), mongoBulkWriteException);
|
||||||
|
}
|
||||||
|
|
||||||
|
throw ex;
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
private WriteModel<Document> extractAndMapWriteModel(SourceAwareWriteModelHolder it) {
|
private WriteModel<Document> extractAndMapWriteModel(SourceAwareWriteModelHolder it) {
|
||||||
@@ -547,15 +552,93 @@ class DefaultBulkOperations implements BulkOperations {
|
|||||||
* @author Christoph Strobl
|
* @author Christoph Strobl
|
||||||
* @since 2.0
|
* @since 2.0
|
||||||
*/
|
*/
|
||||||
@Value
|
static final class BulkOperationContext {
|
||||||
static class BulkOperationContext {
|
|
||||||
|
|
||||||
@NonNull BulkMode bulkMode;
|
private final BulkMode bulkMode;
|
||||||
@NonNull Optional<? extends MongoPersistentEntity<?>> entity;
|
private final Optional<? extends MongoPersistentEntity<?>> entity;
|
||||||
@NonNull QueryMapper queryMapper;
|
private final QueryMapper queryMapper;
|
||||||
@NonNull UpdateMapper updateMapper;
|
private final UpdateMapper updateMapper;
|
||||||
ApplicationEventPublisher eventPublisher;
|
private final ApplicationEventPublisher eventPublisher;
|
||||||
EntityCallbacks entityCallbacks;
|
private final EntityCallbacks entityCallbacks;
|
||||||
|
|
||||||
|
BulkOperationContext(BulkOperations.BulkMode bulkMode, Optional<? extends MongoPersistentEntity<?>> entity,
|
||||||
|
QueryMapper queryMapper, UpdateMapper updateMapper, ApplicationEventPublisher eventPublisher,
|
||||||
|
EntityCallbacks entityCallbacks) {
|
||||||
|
|
||||||
|
this.bulkMode = bulkMode;
|
||||||
|
this.entity = entity;
|
||||||
|
this.queryMapper = queryMapper;
|
||||||
|
this.updateMapper = updateMapper;
|
||||||
|
this.eventPublisher = eventPublisher;
|
||||||
|
this.entityCallbacks = entityCallbacks;
|
||||||
|
}
|
||||||
|
|
||||||
|
public BulkMode getBulkMode() {
|
||||||
|
return this.bulkMode;
|
||||||
|
}
|
||||||
|
|
||||||
|
public Optional<? extends MongoPersistentEntity<?>> getEntity() {
|
||||||
|
return this.entity;
|
||||||
|
}
|
||||||
|
|
||||||
|
public QueryMapper getQueryMapper() {
|
||||||
|
return this.queryMapper;
|
||||||
|
}
|
||||||
|
|
||||||
|
public UpdateMapper getUpdateMapper() {
|
||||||
|
return this.updateMapper;
|
||||||
|
}
|
||||||
|
|
||||||
|
public ApplicationEventPublisher getEventPublisher() {
|
||||||
|
return this.eventPublisher;
|
||||||
|
}
|
||||||
|
|
||||||
|
public EntityCallbacks getEntityCallbacks() {
|
||||||
|
return this.entityCallbacks;
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public boolean equals(Object o) {
|
||||||
|
if (this == o)
|
||||||
|
return true;
|
||||||
|
if (o == null || getClass() != o.getClass())
|
||||||
|
return false;
|
||||||
|
|
||||||
|
BulkOperationContext that = (BulkOperationContext) o;
|
||||||
|
|
||||||
|
if (bulkMode != that.bulkMode)
|
||||||
|
return false;
|
||||||
|
if (!ObjectUtils.nullSafeEquals(this.entity, that.entity)) {
|
||||||
|
return false;
|
||||||
|
}
|
||||||
|
if (!ObjectUtils.nullSafeEquals(this.queryMapper, that.queryMapper)) {
|
||||||
|
return false;
|
||||||
|
}
|
||||||
|
if (!ObjectUtils.nullSafeEquals(this.updateMapper, that.updateMapper)) {
|
||||||
|
return false;
|
||||||
|
}
|
||||||
|
if (!ObjectUtils.nullSafeEquals(this.eventPublisher, that.eventPublisher)) {
|
||||||
|
return false;
|
||||||
|
}
|
||||||
|
return ObjectUtils.nullSafeEquals(this.entityCallbacks, that.entityCallbacks);
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public int hashCode() {
|
||||||
|
int result = bulkMode != null ? bulkMode.hashCode() : 0;
|
||||||
|
result = 31 * result + ObjectUtils.nullSafeHashCode(entity);
|
||||||
|
result = 31 * result + ObjectUtils.nullSafeHashCode(queryMapper);
|
||||||
|
result = 31 * result + ObjectUtils.nullSafeHashCode(updateMapper);
|
||||||
|
result = 31 * result + ObjectUtils.nullSafeHashCode(eventPublisher);
|
||||||
|
result = 31 * result + ObjectUtils.nullSafeHashCode(entityCallbacks);
|
||||||
|
return result;
|
||||||
|
}
|
||||||
|
|
||||||
|
public String toString() {
|
||||||
|
return "DefaultBulkOperations.BulkOperationContext(bulkMode=" + this.getBulkMode() + ", entity="
|
||||||
|
+ this.getEntity() + ", queryMapper=" + this.getQueryMapper() + ", updateMapper=" + this.getUpdateMapper()
|
||||||
|
+ ", eventPublisher=" + this.getEventPublisher() + ", entityCallbacks=" + this.getEntityCallbacks() + ")";
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
@@ -564,10 +647,50 @@ class DefaultBulkOperations implements BulkOperations {
|
|||||||
* @since 2.2
|
* @since 2.2
|
||||||
* @author Christoph Strobl
|
* @author Christoph Strobl
|
||||||
*/
|
*/
|
||||||
@Value
|
private static final class SourceAwareWriteModelHolder {
|
||||||
private static class SourceAwareWriteModelHolder {
|
|
||||||
|
|
||||||
Object source;
|
private final Object source;
|
||||||
WriteModel<Document> model;
|
private final WriteModel<Document> model;
|
||||||
|
|
||||||
|
SourceAwareWriteModelHolder(Object source, WriteModel<Document> model) {
|
||||||
|
|
||||||
|
this.source = source;
|
||||||
|
this.model = model;
|
||||||
|
}
|
||||||
|
|
||||||
|
public Object getSource() {
|
||||||
|
return this.source;
|
||||||
|
}
|
||||||
|
|
||||||
|
public WriteModel<Document> getModel() {
|
||||||
|
return this.model;
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public boolean equals(Object o) {
|
||||||
|
if (this == o)
|
||||||
|
return true;
|
||||||
|
if (o == null || getClass() != o.getClass())
|
||||||
|
return false;
|
||||||
|
|
||||||
|
SourceAwareWriteModelHolder that = (SourceAwareWriteModelHolder) o;
|
||||||
|
|
||||||
|
if (!ObjectUtils.nullSafeEquals(this.source, that.source)) {
|
||||||
|
return false;
|
||||||
|
}
|
||||||
|
return ObjectUtils.nullSafeEquals(this.model, that.model);
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public int hashCode() {
|
||||||
|
int result = ObjectUtils.nullSafeHashCode(model);
|
||||||
|
result = 31 * result + ObjectUtils.nullSafeHashCode(source);
|
||||||
|
return result;
|
||||||
|
}
|
||||||
|
|
||||||
|
public String toString() {
|
||||||
|
return "DefaultBulkOperations.SourceAwareWriteModelHolder(source=" + this.getSource() + ", model="
|
||||||
|
+ this.getModel() + ")";
|
||||||
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -1,5 +1,5 @@
|
|||||||
/*
|
/*
|
||||||
* Copyright 2011-2020 the original author or authors.
|
* Copyright 2011-2021 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-2020 the original author or authors.
|
* Copyright 2016-2021 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-2020 the original author or authors.
|
* Copyright 2016-2021 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-2020 the original author or authors.
|
* Copyright 2014-2021 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-2020 the original author or authors.
|
* Copyright 2015-2021 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-2020 the original author or authors.
|
* Copyright 2010-2021 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-2020 the original author or authors.
|
* Copyright 2018-2021 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,10 +15,6 @@
|
|||||||
*/
|
*/
|
||||||
package org.springframework.data.mongodb.core;
|
package org.springframework.data.mongodb.core;
|
||||||
|
|
||||||
import lombok.AccessLevel;
|
|
||||||
import lombok.NonNull;
|
|
||||||
import lombok.RequiredArgsConstructor;
|
|
||||||
|
|
||||||
import java.util.Collection;
|
import java.util.Collection;
|
||||||
import java.util.Map;
|
import java.util.Map;
|
||||||
import java.util.Optional;
|
import java.util.Optional;
|
||||||
@@ -55,12 +51,15 @@ import org.springframework.util.MultiValueMap;
|
|||||||
* @see MongoTemplate
|
* @see MongoTemplate
|
||||||
* @see ReactiveMongoTemplate
|
* @see ReactiveMongoTemplate
|
||||||
*/
|
*/
|
||||||
@RequiredArgsConstructor
|
|
||||||
class EntityOperations {
|
class EntityOperations {
|
||||||
|
|
||||||
private static final String ID_FIELD = "_id";
|
private static final String ID_FIELD = "_id";
|
||||||
|
|
||||||
private final @NonNull MappingContext<? extends MongoPersistentEntity<?>, MongoPersistentProperty> context;
|
private final MappingContext<? extends MongoPersistentEntity<?>, MongoPersistentProperty> context;
|
||||||
|
|
||||||
|
EntityOperations(MappingContext<? extends MongoPersistentEntity<?>, MongoPersistentProperty> context) {
|
||||||
|
this.context = context;
|
||||||
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Creates a new {@link Entity} for the given bean.
|
* Creates a new {@link Entity} for the given bean.
|
||||||
@@ -69,7 +68,7 @@ class EntityOperations {
|
|||||||
* @return new instance of {@link Entity}.
|
* @return new instance of {@link Entity}.
|
||||||
*/
|
*/
|
||||||
@SuppressWarnings({ "unchecked", "rawtypes" })
|
@SuppressWarnings({ "unchecked", "rawtypes" })
|
||||||
public <T> Entity<T> forEntity(T entity) {
|
<T> Entity<T> forEntity(T entity) {
|
||||||
|
|
||||||
Assert.notNull(entity, "Bean must not be null!");
|
Assert.notNull(entity, "Bean must not be null!");
|
||||||
|
|
||||||
@@ -92,7 +91,7 @@ class EntityOperations {
|
|||||||
* @return new instance of {@link AdaptibleEntity}.
|
* @return new instance of {@link AdaptibleEntity}.
|
||||||
*/
|
*/
|
||||||
@SuppressWarnings({ "unchecked", "rawtypes" })
|
@SuppressWarnings({ "unchecked", "rawtypes" })
|
||||||
public <T> AdaptibleEntity<T> forEntity(T entity, ConversionService conversionService) {
|
<T> AdaptibleEntity<T> forEntity(T entity, ConversionService conversionService) {
|
||||||
|
|
||||||
Assert.notNull(entity, "Bean must not be null!");
|
Assert.notNull(entity, "Bean must not be null!");
|
||||||
Assert.notNull(conversionService, "ConversionService must not be null!");
|
Assert.notNull(conversionService, "ConversionService must not be null!");
|
||||||
@@ -346,11 +345,14 @@ class EntityOperations {
|
|||||||
Number getVersion();
|
Number getVersion();
|
||||||
}
|
}
|
||||||
|
|
||||||
@RequiredArgsConstructor
|
|
||||||
private static class UnmappedEntity<T extends Map<String, Object>> implements AdaptibleEntity<T> {
|
private static class UnmappedEntity<T extends Map<String, Object>> implements AdaptibleEntity<T> {
|
||||||
|
|
||||||
private final T map;
|
private final T map;
|
||||||
|
|
||||||
|
protected UnmappedEntity(T map) {
|
||||||
|
this.map = map;
|
||||||
|
}
|
||||||
|
|
||||||
/*
|
/*
|
||||||
* (non-Javadoc)
|
* (non-Javadoc)
|
||||||
* @see org.springframework.data.mongodb.core.EntityOperations.PersistableSource#getIdPropertyName()
|
* @see org.springframework.data.mongodb.core.EntityOperations.PersistableSource#getIdPropertyName()
|
||||||
@@ -460,7 +462,7 @@ class EntityOperations {
|
|||||||
|
|
||||||
private static class SimpleMappedEntity<T extends Map<String, Object>> extends UnmappedEntity<T> {
|
private static class SimpleMappedEntity<T extends Map<String, Object>> extends UnmappedEntity<T> {
|
||||||
|
|
||||||
SimpleMappedEntity(T map) {
|
protected SimpleMappedEntity(T map) {
|
||||||
super(map);
|
super(map);
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -483,12 +485,19 @@ class EntityOperations {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
@RequiredArgsConstructor(access = AccessLevel.PROTECTED)
|
|
||||||
private static class MappedEntity<T> implements Entity<T> {
|
private static class MappedEntity<T> implements Entity<T> {
|
||||||
|
|
||||||
private final @NonNull MongoPersistentEntity<?> entity;
|
private final MongoPersistentEntity<?> entity;
|
||||||
private final @NonNull IdentifierAccessor idAccessor;
|
private final IdentifierAccessor idAccessor;
|
||||||
private final @NonNull PersistentPropertyAccessor<T> propertyAccessor;
|
private final PersistentPropertyAccessor<T> propertyAccessor;
|
||||||
|
|
||||||
|
protected MappedEntity(MongoPersistentEntity<?> entity, IdentifierAccessor idAccessor,
|
||||||
|
PersistentPropertyAccessor<T> propertyAccessor) {
|
||||||
|
|
||||||
|
this.entity = entity;
|
||||||
|
this.idAccessor = idAccessor;
|
||||||
|
this.propertyAccessor = propertyAccessor;
|
||||||
|
}
|
||||||
|
|
||||||
private static <T> MappedEntity<T> of(T bean,
|
private static <T> MappedEntity<T> of(T bean,
|
||||||
MappingContext<? extends MongoPersistentEntity<?>, MongoPersistentProperty> context) {
|
MappingContext<? extends MongoPersistentEntity<?>, MongoPersistentProperty> context) {
|
||||||
@@ -759,11 +768,12 @@ class EntityOperations {
|
|||||||
* {@link TypedOperations} for generic entities that are not represented with {@link PersistentEntity} (e.g. custom
|
* {@link TypedOperations} for generic entities that are not represented with {@link PersistentEntity} (e.g. custom
|
||||||
* conversions).
|
* conversions).
|
||||||
*/
|
*/
|
||||||
@RequiredArgsConstructor
|
|
||||||
enum UntypedOperations implements TypedOperations<Object> {
|
enum UntypedOperations implements TypedOperations<Object> {
|
||||||
|
|
||||||
INSTANCE;
|
INSTANCE;
|
||||||
|
|
||||||
|
UntypedOperations() {}
|
||||||
|
|
||||||
@SuppressWarnings({ "unchecked", "rawtypes" })
|
@SuppressWarnings({ "unchecked", "rawtypes" })
|
||||||
public static <T> TypedOperations<T> instance() {
|
public static <T> TypedOperations<T> instance() {
|
||||||
return (TypedOperations) INSTANCE;
|
return (TypedOperations) INSTANCE;
|
||||||
@@ -798,10 +808,13 @@ class EntityOperations {
|
|||||||
*
|
*
|
||||||
* @param <T>
|
* @param <T>
|
||||||
*/
|
*/
|
||||||
@RequiredArgsConstructor
|
|
||||||
static class TypedEntityOperations<T> implements TypedOperations<T> {
|
static class TypedEntityOperations<T> implements TypedOperations<T> {
|
||||||
|
|
||||||
private final @NonNull MongoPersistentEntity<T> entity;
|
private final MongoPersistentEntity<T> entity;
|
||||||
|
|
||||||
|
protected TypedEntityOperations(MongoPersistentEntity<T> entity) {
|
||||||
|
this.entity = entity;
|
||||||
|
}
|
||||||
|
|
||||||
/*
|
/*
|
||||||
* (non-Javadoc)
|
* (non-Javadoc)
|
||||||
|
|||||||
@@ -1,5 +1,5 @@
|
|||||||
/*
|
/*
|
||||||
* Copyright 2017-2020 the original author or authors.
|
* Copyright 2017-2021 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-2020 the original author or authors.
|
* Copyright 2017-2021 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,16 +15,10 @@
|
|||||||
*/
|
*/
|
||||||
package org.springframework.data.mongodb.core;
|
package org.springframework.data.mongodb.core;
|
||||||
|
|
||||||
import lombok.AccessLevel;
|
|
||||||
import lombok.NonNull;
|
|
||||||
import lombok.RequiredArgsConstructor;
|
|
||||||
import lombok.experimental.FieldDefaults;
|
|
||||||
|
|
||||||
import org.springframework.data.mongodb.core.aggregation.Aggregation;
|
import org.springframework.data.mongodb.core.aggregation.Aggregation;
|
||||||
import org.springframework.data.mongodb.core.aggregation.AggregationResults;
|
import org.springframework.data.mongodb.core.aggregation.AggregationResults;
|
||||||
import org.springframework.data.mongodb.core.aggregation.TypedAggregation;
|
import org.springframework.data.mongodb.core.aggregation.TypedAggregation;
|
||||||
import org.springframework.data.util.CloseableIterator;
|
import org.springframework.data.util.CloseableIterator;
|
||||||
import org.springframework.lang.Nullable;
|
|
||||||
import org.springframework.util.Assert;
|
import org.springframework.util.Assert;
|
||||||
import org.springframework.util.StringUtils;
|
import org.springframework.util.StringUtils;
|
||||||
|
|
||||||
@@ -35,10 +29,13 @@ import org.springframework.util.StringUtils;
|
|||||||
* @author Mark Paluch
|
* @author Mark Paluch
|
||||||
* @since 2.0
|
* @since 2.0
|
||||||
*/
|
*/
|
||||||
@RequiredArgsConstructor
|
|
||||||
class ExecutableAggregationOperationSupport implements ExecutableAggregationOperation {
|
class ExecutableAggregationOperationSupport implements ExecutableAggregationOperation {
|
||||||
|
|
||||||
private final @NonNull MongoTemplate template;
|
private final MongoTemplate template;
|
||||||
|
|
||||||
|
ExecutableAggregationOperationSupport(MongoTemplate template) {
|
||||||
|
this.template = template;
|
||||||
|
}
|
||||||
|
|
||||||
/*
|
/*
|
||||||
* (non-Javadoc)
|
* (non-Javadoc)
|
||||||
@@ -56,15 +53,21 @@ class ExecutableAggregationOperationSupport implements ExecutableAggregationOper
|
|||||||
* @author Christoph Strobl
|
* @author Christoph Strobl
|
||||||
* @since 2.0
|
* @since 2.0
|
||||||
*/
|
*/
|
||||||
@RequiredArgsConstructor
|
|
||||||
@FieldDefaults(level = AccessLevel.PRIVATE, makeFinal = true)
|
|
||||||
static class ExecutableAggregationSupport<T>
|
static class ExecutableAggregationSupport<T>
|
||||||
implements AggregationWithAggregation<T>, ExecutableAggregation<T>, TerminatingAggregation<T> {
|
implements AggregationWithAggregation<T>, ExecutableAggregation<T>, TerminatingAggregation<T> {
|
||||||
|
|
||||||
@NonNull MongoTemplate template;
|
private final MongoTemplate template;
|
||||||
@NonNull Class<T> domainType;
|
private final Class<T> domainType;
|
||||||
@Nullable Aggregation aggregation;
|
private final Aggregation aggregation;
|
||||||
@Nullable String collection;
|
private final String collection;
|
||||||
|
|
||||||
|
public ExecutableAggregationSupport(MongoTemplate template, Class<T> domainType, Aggregation aggregation,
|
||||||
|
String collection) {
|
||||||
|
this.template = template;
|
||||||
|
this.domainType = domainType;
|
||||||
|
this.aggregation = aggregation;
|
||||||
|
this.collection = collection;
|
||||||
|
}
|
||||||
|
|
||||||
/*
|
/*
|
||||||
* (non-Javadoc)
|
* (non-Javadoc)
|
||||||
|
|||||||
@@ -1,5 +1,5 @@
|
|||||||
/*
|
/*
|
||||||
* Copyright 2017-2020 the original author or authors.
|
* Copyright 2017-2021 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,6 +125,11 @@ public interface ExecutableFindOperation {
|
|||||||
|
|
||||||
/**
|
/**
|
||||||
* Get the number of matching elements.
|
* Get the number of matching elements.
|
||||||
|
* <p />
|
||||||
|
* 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,
|
||||||
|
* session and transaction compliance. In case an inaccurate count satisfies the applications needs use
|
||||||
|
* {@link MongoOperations#estimatedCount(String)} for empty queries instead.
|
||||||
*
|
*
|
||||||
* @return total number of matching elements.
|
* @return total number of matching elements.
|
||||||
*/
|
*/
|
||||||
|
|||||||
@@ -1,5 +1,5 @@
|
|||||||
/*
|
/*
|
||||||
* Copyright 2017-2020 the original author or authors.
|
* Copyright 2017-2021 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,12 +15,6 @@
|
|||||||
*/
|
*/
|
||||||
package org.springframework.data.mongodb.core;
|
package org.springframework.data.mongodb.core;
|
||||||
|
|
||||||
import com.mongodb.ReadPreference;
|
|
||||||
import lombok.AccessLevel;
|
|
||||||
import lombok.NonNull;
|
|
||||||
import lombok.RequiredArgsConstructor;
|
|
||||||
import lombok.experimental.FieldDefaults;
|
|
||||||
|
|
||||||
import java.util.List;
|
import java.util.List;
|
||||||
import java.util.Optional;
|
import java.util.Optional;
|
||||||
import java.util.stream.Stream;
|
import java.util.stream.Stream;
|
||||||
@@ -37,6 +31,7 @@ import org.springframework.util.Assert;
|
|||||||
import org.springframework.util.ObjectUtils;
|
import org.springframework.util.ObjectUtils;
|
||||||
import org.springframework.util.StringUtils;
|
import org.springframework.util.StringUtils;
|
||||||
|
|
||||||
|
import com.mongodb.ReadPreference;
|
||||||
import com.mongodb.client.FindIterable;
|
import com.mongodb.client.FindIterable;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
@@ -46,12 +41,15 @@ import com.mongodb.client.FindIterable;
|
|||||||
* @author Mark Paluch
|
* @author Mark Paluch
|
||||||
* @since 2.0
|
* @since 2.0
|
||||||
*/
|
*/
|
||||||
@RequiredArgsConstructor
|
|
||||||
class ExecutableFindOperationSupport implements ExecutableFindOperation {
|
class ExecutableFindOperationSupport implements ExecutableFindOperation {
|
||||||
|
|
||||||
private static final Query ALL_QUERY = new Query();
|
private static final Query ALL_QUERY = new Query();
|
||||||
|
|
||||||
private final @NonNull MongoTemplate template;
|
private final MongoTemplate template;
|
||||||
|
|
||||||
|
ExecutableFindOperationSupport(MongoTemplate template) {
|
||||||
|
this.template = template;
|
||||||
|
}
|
||||||
|
|
||||||
/*
|
/*
|
||||||
* (non-Javadoc)
|
* (non-Javadoc)
|
||||||
@@ -70,16 +68,23 @@ class ExecutableFindOperationSupport implements ExecutableFindOperation {
|
|||||||
* @author Christoph Strobl
|
* @author Christoph Strobl
|
||||||
* @since 2.0
|
* @since 2.0
|
||||||
*/
|
*/
|
||||||
@RequiredArgsConstructor
|
|
||||||
@FieldDefaults(level = AccessLevel.PRIVATE, makeFinal = true)
|
|
||||||
static class ExecutableFindSupport<T>
|
static class ExecutableFindSupport<T>
|
||||||
implements ExecutableFind<T>, FindWithCollection<T>, FindWithProjection<T>, FindWithQuery<T> {
|
implements ExecutableFind<T>, FindWithCollection<T>, FindWithProjection<T>, FindWithQuery<T> {
|
||||||
|
|
||||||
@NonNull MongoTemplate template;
|
private final MongoTemplate template;
|
||||||
@NonNull Class<?> domainType;
|
private final Class<?> domainType;
|
||||||
Class<T> returnType;
|
private final Class<T> returnType;
|
||||||
@Nullable String collection;
|
@Nullable private final String collection;
|
||||||
Query query;
|
private final Query query;
|
||||||
|
|
||||||
|
ExecutableFindSupport(MongoTemplate template, Class<?> domainType, Class<T> returnType,
|
||||||
|
String collection, Query query) {
|
||||||
|
this.template = template;
|
||||||
|
this.domainType = domainType;
|
||||||
|
this.returnType = returnType;
|
||||||
|
this.collection = collection;
|
||||||
|
this.query = query;
|
||||||
|
}
|
||||||
|
|
||||||
/*
|
/*
|
||||||
* (non-Javadoc)
|
* (non-Javadoc)
|
||||||
|
|||||||
@@ -1,5 +1,5 @@
|
|||||||
/*
|
/*
|
||||||
* Copyright 2017-2020 the original author or authors.
|
* Copyright 2017-2021 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-2020 the original author or authors.
|
* Copyright 2017-2021 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,11 +15,6 @@
|
|||||||
*/
|
*/
|
||||||
package org.springframework.data.mongodb.core;
|
package org.springframework.data.mongodb.core;
|
||||||
|
|
||||||
import lombok.AccessLevel;
|
|
||||||
import lombok.NonNull;
|
|
||||||
import lombok.RequiredArgsConstructor;
|
|
||||||
import lombok.experimental.FieldDefaults;
|
|
||||||
|
|
||||||
import java.util.ArrayList;
|
import java.util.ArrayList;
|
||||||
import java.util.Collection;
|
import java.util.Collection;
|
||||||
|
|
||||||
@@ -37,10 +32,13 @@ import com.mongodb.bulk.BulkWriteResult;
|
|||||||
* @author Mark Paluch
|
* @author Mark Paluch
|
||||||
* @since 2.0
|
* @since 2.0
|
||||||
*/
|
*/
|
||||||
@RequiredArgsConstructor
|
|
||||||
class ExecutableInsertOperationSupport implements ExecutableInsertOperation {
|
class ExecutableInsertOperationSupport implements ExecutableInsertOperation {
|
||||||
|
|
||||||
private final @NonNull MongoTemplate template;
|
private final MongoTemplate template;
|
||||||
|
|
||||||
|
ExecutableInsertOperationSupport(MongoTemplate template) {
|
||||||
|
this.template = template;
|
||||||
|
}
|
||||||
|
|
||||||
/*
|
/*
|
||||||
* (non-Javadoc)
|
* (non-Javadoc)
|
||||||
@@ -58,14 +56,20 @@ class ExecutableInsertOperationSupport implements ExecutableInsertOperation {
|
|||||||
* @author Christoph Strobl
|
* @author Christoph Strobl
|
||||||
* @since 2.0
|
* @since 2.0
|
||||||
*/
|
*/
|
||||||
@RequiredArgsConstructor
|
|
||||||
@FieldDefaults(level = AccessLevel.PRIVATE, makeFinal = true)
|
|
||||||
static class ExecutableInsertSupport<T> implements ExecutableInsert<T> {
|
static class ExecutableInsertSupport<T> implements ExecutableInsert<T> {
|
||||||
|
|
||||||
@NonNull MongoTemplate template;
|
private final MongoTemplate template;
|
||||||
@NonNull Class<T> domainType;
|
private final Class<T> domainType;
|
||||||
@Nullable String collection;
|
@Nullable private final String collection;
|
||||||
@Nullable BulkMode bulkMode;
|
@Nullable private final BulkMode bulkMode;
|
||||||
|
|
||||||
|
ExecutableInsertSupport(MongoTemplate template, Class<T> domainType, String collection, BulkMode bulkMode) {
|
||||||
|
|
||||||
|
this.template = template;
|
||||||
|
this.domainType = domainType;
|
||||||
|
this.collection = collection;
|
||||||
|
this.bulkMode = bulkMode;
|
||||||
|
}
|
||||||
|
|
||||||
/*
|
/*
|
||||||
* (non-Javadoc)
|
* (non-Javadoc)
|
||||||
|
|||||||
@@ -1,5 +1,5 @@
|
|||||||
/*
|
/*
|
||||||
* Copyright 2018-2020 the original author or authors.
|
* Copyright 2018-2021 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-2020 the original author or authors.
|
* Copyright 2018-2021 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,9 +15,6 @@
|
|||||||
*/
|
*/
|
||||||
package org.springframework.data.mongodb.core;
|
package org.springframework.data.mongodb.core;
|
||||||
|
|
||||||
import lombok.NonNull;
|
|
||||||
import lombok.RequiredArgsConstructor;
|
|
||||||
|
|
||||||
import java.util.List;
|
import java.util.List;
|
||||||
|
|
||||||
import org.springframework.data.mongodb.core.mapreduce.MapReduceOptions;
|
import org.springframework.data.mongodb.core.mapreduce.MapReduceOptions;
|
||||||
@@ -32,12 +29,17 @@ import org.springframework.util.StringUtils;
|
|||||||
* @author Christoph Strobl
|
* @author Christoph Strobl
|
||||||
* @since 2.1
|
* @since 2.1
|
||||||
*/
|
*/
|
||||||
@RequiredArgsConstructor
|
|
||||||
class ExecutableMapReduceOperationSupport implements ExecutableMapReduceOperation {
|
class ExecutableMapReduceOperationSupport implements ExecutableMapReduceOperation {
|
||||||
|
|
||||||
private static final Query ALL_QUERY = new Query();
|
private static final Query ALL_QUERY = new Query();
|
||||||
|
|
||||||
private final @NonNull MongoTemplate template;
|
private final MongoTemplate template;
|
||||||
|
|
||||||
|
ExecutableMapReduceOperationSupport(MongoTemplate template) {
|
||||||
|
|
||||||
|
Assert.notNull(template, "Template must not be null!");
|
||||||
|
this.template = template;
|
||||||
|
}
|
||||||
|
|
||||||
/*
|
/*
|
||||||
* (non-Javascript)
|
* (non-Javascript)
|
||||||
|
|||||||
@@ -1,5 +1,5 @@
|
|||||||
/*
|
/*
|
||||||
* Copyright 2017-2020 the original author or authors.
|
* Copyright 2017-2021 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-2020 the original author or authors.
|
* Copyright 2017-2021 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,11 +15,6 @@
|
|||||||
*/
|
*/
|
||||||
package org.springframework.data.mongodb.core;
|
package org.springframework.data.mongodb.core;
|
||||||
|
|
||||||
import lombok.AccessLevel;
|
|
||||||
import lombok.NonNull;
|
|
||||||
import lombok.RequiredArgsConstructor;
|
|
||||||
import lombok.experimental.FieldDefaults;
|
|
||||||
|
|
||||||
import java.util.List;
|
import java.util.List;
|
||||||
|
|
||||||
import org.springframework.data.mongodb.core.query.Query;
|
import org.springframework.data.mongodb.core.query.Query;
|
||||||
@@ -36,12 +31,15 @@ import com.mongodb.client.result.DeleteResult;
|
|||||||
* @author Mark Paluch
|
* @author Mark Paluch
|
||||||
* @since 2.0
|
* @since 2.0
|
||||||
*/
|
*/
|
||||||
@RequiredArgsConstructor
|
|
||||||
class ExecutableRemoveOperationSupport implements ExecutableRemoveOperation {
|
class ExecutableRemoveOperationSupport implements ExecutableRemoveOperation {
|
||||||
|
|
||||||
private static final Query ALL_QUERY = new Query();
|
private static final Query ALL_QUERY = new Query();
|
||||||
|
|
||||||
private final @NonNull MongoTemplate tempate;
|
private final MongoTemplate tempate;
|
||||||
|
|
||||||
|
public ExecutableRemoveOperationSupport(MongoTemplate tempate) {
|
||||||
|
this.tempate = tempate;
|
||||||
|
}
|
||||||
|
|
||||||
/*
|
/*
|
||||||
* (non-Javadoc)
|
* (non-Javadoc)
|
||||||
@@ -59,14 +57,19 @@ class ExecutableRemoveOperationSupport implements ExecutableRemoveOperation {
|
|||||||
* @author Christoph Strobl
|
* @author Christoph Strobl
|
||||||
* @since 2.0
|
* @since 2.0
|
||||||
*/
|
*/
|
||||||
@RequiredArgsConstructor
|
|
||||||
@FieldDefaults(level = AccessLevel.PRIVATE, makeFinal = true)
|
|
||||||
static class ExecutableRemoveSupport<T> implements ExecutableRemove<T>, RemoveWithCollection<T> {
|
static class ExecutableRemoveSupport<T> implements ExecutableRemove<T>, RemoveWithCollection<T> {
|
||||||
|
|
||||||
@NonNull MongoTemplate template;
|
private final MongoTemplate template;
|
||||||
@NonNull Class<T> domainType;
|
private final Class<T> domainType;
|
||||||
Query query;
|
private final Query query;
|
||||||
@Nullable String collection;
|
@Nullable private final String collection;
|
||||||
|
|
||||||
|
public ExecutableRemoveSupport(MongoTemplate template, Class<T> domainType, Query query, String collection) {
|
||||||
|
this.template = template;
|
||||||
|
this.domainType = domainType;
|
||||||
|
this.query = query;
|
||||||
|
this.collection = collection;
|
||||||
|
}
|
||||||
|
|
||||||
/*
|
/*
|
||||||
* (non-Javadoc)
|
* (non-Javadoc)
|
||||||
|
|||||||
@@ -1,5 +1,5 @@
|
|||||||
/*
|
/*
|
||||||
* Copyright 2017-2020 the original author or authors.
|
* Copyright 2017-2021 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-2020 the original author or authors.
|
* Copyright 2017-2021 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,11 +15,6 @@
|
|||||||
*/
|
*/
|
||||||
package org.springframework.data.mongodb.core;
|
package org.springframework.data.mongodb.core;
|
||||||
|
|
||||||
import lombok.AccessLevel;
|
|
||||||
import lombok.NonNull;
|
|
||||||
import lombok.RequiredArgsConstructor;
|
|
||||||
import lombok.experimental.FieldDefaults;
|
|
||||||
|
|
||||||
import org.springframework.data.mongodb.core.query.Query;
|
import org.springframework.data.mongodb.core.query.Query;
|
||||||
import org.springframework.data.mongodb.core.query.UpdateDefinition;
|
import org.springframework.data.mongodb.core.query.UpdateDefinition;
|
||||||
import org.springframework.lang.Nullable;
|
import org.springframework.lang.Nullable;
|
||||||
@@ -35,12 +30,15 @@ import com.mongodb.client.result.UpdateResult;
|
|||||||
* @author Mark Paluch
|
* @author Mark Paluch
|
||||||
* @since 2.0
|
* @since 2.0
|
||||||
*/
|
*/
|
||||||
@RequiredArgsConstructor
|
|
||||||
class ExecutableUpdateOperationSupport implements ExecutableUpdateOperation {
|
class ExecutableUpdateOperationSupport implements ExecutableUpdateOperation {
|
||||||
|
|
||||||
private static final Query ALL_QUERY = new Query();
|
private static final Query ALL_QUERY = new Query();
|
||||||
|
|
||||||
private final @NonNull MongoTemplate template;
|
private final MongoTemplate template;
|
||||||
|
|
||||||
|
ExecutableUpdateOperationSupport(MongoTemplate template) {
|
||||||
|
this.template = template;
|
||||||
|
}
|
||||||
|
|
||||||
/*
|
/*
|
||||||
* (non-Javadoc)
|
* (non-Javadoc)
|
||||||
@@ -58,21 +56,34 @@ class ExecutableUpdateOperationSupport implements ExecutableUpdateOperation {
|
|||||||
* @author Christoph Strobl
|
* @author Christoph Strobl
|
||||||
* @since 2.0
|
* @since 2.0
|
||||||
*/
|
*/
|
||||||
@RequiredArgsConstructor
|
|
||||||
@FieldDefaults(level = AccessLevel.PRIVATE, makeFinal = true)
|
|
||||||
static class ExecutableUpdateSupport<T>
|
static class ExecutableUpdateSupport<T>
|
||||||
implements ExecutableUpdate<T>, UpdateWithCollection<T>, UpdateWithQuery<T>, TerminatingUpdate<T>,
|
implements ExecutableUpdate<T>, UpdateWithCollection<T>, UpdateWithQuery<T>, TerminatingUpdate<T>,
|
||||||
FindAndReplaceWithOptions<T>, TerminatingFindAndReplace<T>, FindAndReplaceWithProjection<T> {
|
FindAndReplaceWithOptions<T>, TerminatingFindAndReplace<T>, FindAndReplaceWithProjection<T> {
|
||||||
|
|
||||||
@NonNull MongoTemplate template;
|
private final MongoTemplate template;
|
||||||
@NonNull Class domainType;
|
private final Class domainType;
|
||||||
Query query;
|
private final Query query;
|
||||||
@Nullable UpdateDefinition update;
|
@Nullable private final UpdateDefinition update;
|
||||||
@Nullable String collection;
|
@Nullable private final String collection;
|
||||||
@Nullable FindAndModifyOptions findAndModifyOptions;
|
@Nullable private final FindAndModifyOptions findAndModifyOptions;
|
||||||
@Nullable FindAndReplaceOptions findAndReplaceOptions;
|
@Nullable private final FindAndReplaceOptions findAndReplaceOptions;
|
||||||
@Nullable Object replacement;
|
@Nullable private final Object replacement;
|
||||||
@NonNull Class<T> targetType;
|
private final Class<T> targetType;
|
||||||
|
|
||||||
|
ExecutableUpdateSupport(MongoTemplate template, Class domainType, Query query, UpdateDefinition update,
|
||||||
|
String collection, FindAndModifyOptions findAndModifyOptions, FindAndReplaceOptions findAndReplaceOptions,
|
||||||
|
Object replacement, Class<T> targetType) {
|
||||||
|
|
||||||
|
this.template = template;
|
||||||
|
this.domainType = domainType;
|
||||||
|
this.query = query;
|
||||||
|
this.update = update;
|
||||||
|
this.collection = collection;
|
||||||
|
this.findAndModifyOptions = findAndModifyOptions;
|
||||||
|
this.findAndReplaceOptions = findAndReplaceOptions;
|
||||||
|
this.replacement = replacement;
|
||||||
|
this.targetType = targetType;
|
||||||
|
}
|
||||||
|
|
||||||
/*
|
/*
|
||||||
* (non-Javadoc)
|
* (non-Javadoc)
|
||||||
|
|||||||
@@ -1,5 +1,5 @@
|
|||||||
/*
|
/*
|
||||||
* Copyright 2010-2020 the original author or authors.
|
* Copyright 2010-2021 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-2020 the original author or authors.
|
* Copyright 2018-2021 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-2020 the original author or authors.
|
* Copyright 2016-2021 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-2020 the original author or authors.
|
* Copyright 2017-2021 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-2020 the original author or authors.
|
* Copyright 2016-2021 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-2020 the original author or authors.
|
* Copyright 2016-2021 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-2020 the original author or authors.
|
* Copyright 2018-2021 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,9 +15,6 @@
|
|||||||
*/
|
*/
|
||||||
package org.springframework.data.mongodb.core;
|
package org.springframework.data.mongodb.core;
|
||||||
|
|
||||||
import lombok.Getter;
|
|
||||||
import lombok.RequiredArgsConstructor;
|
|
||||||
|
|
||||||
import java.util.Collection;
|
import java.util.Collection;
|
||||||
import java.util.List;
|
import java.util.List;
|
||||||
|
|
||||||
@@ -27,8 +24,6 @@ import org.springframework.data.mongodb.core.query.Update;
|
|||||||
import org.springframework.data.mongodb.core.query.UpdateDefinition;
|
import org.springframework.data.mongodb.core.query.UpdateDefinition;
|
||||||
import org.springframework.data.util.StreamUtils;
|
import org.springframework.data.util.StreamUtils;
|
||||||
|
|
||||||
import com.mongodb.client.model.Filters;
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* A MongoDB document in its mapped state. I.e. after a source document has been mapped using mapping information of the
|
* A MongoDB document in its mapped state. I.e. after a source document has been mapped using mapping information of the
|
||||||
* entity the source document was supposed to represent.
|
* entity the source document was supposed to represent.
|
||||||
@@ -36,13 +31,20 @@ import com.mongodb.client.model.Filters;
|
|||||||
* @author Oliver Gierke
|
* @author Oliver Gierke
|
||||||
* @since 2.1
|
* @since 2.1
|
||||||
*/
|
*/
|
||||||
@RequiredArgsConstructor(staticName = "of")
|
|
||||||
public class MappedDocument {
|
public class MappedDocument {
|
||||||
|
|
||||||
private static final String ID_FIELD = "_id";
|
private static final String ID_FIELD = "_id";
|
||||||
private static final Document ID_ONLY_PROJECTION = new Document(ID_FIELD, 1);
|
private static final Document ID_ONLY_PROJECTION = new Document(ID_FIELD, 1);
|
||||||
|
|
||||||
private final @Getter Document document;
|
private final Document document;
|
||||||
|
|
||||||
|
private MappedDocument(Document document) {
|
||||||
|
this.document = document;
|
||||||
|
}
|
||||||
|
|
||||||
|
public static MappedDocument of(Document document) {
|
||||||
|
return new MappedDocument(document);
|
||||||
|
}
|
||||||
|
|
||||||
public static Document getIdOnlyProjection() {
|
public static Document getIdOnlyProjection() {
|
||||||
return ID_ONLY_PROJECTION;
|
return ID_ONLY_PROJECTION;
|
||||||
@@ -91,6 +93,10 @@ public class MappedDocument {
|
|||||||
return new MappedUpdate(Update.fromDocument(document, ID_FIELD));
|
return new MappedUpdate(Update.fromDocument(document, ID_FIELD));
|
||||||
}
|
}
|
||||||
|
|
||||||
|
public Document getDocument() {
|
||||||
|
return this.document;
|
||||||
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* An {@link UpdateDefinition} that indicates that the {@link #getUpdateObject() update object} has already been
|
* An {@link UpdateDefinition} that indicates that the {@link #getUpdateObject() update object} has already been
|
||||||
* mapped to the specific domain type.
|
* mapped to the specific domain type.
|
||||||
|
|||||||
@@ -1,5 +1,5 @@
|
|||||||
/*
|
/*
|
||||||
* Copyright 2019-2020 the original author or authors.
|
* Copyright 2019-2021 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