Compare commits
6 Commits
| Author | SHA1 | Date | |
|---|---|---|---|
|
|
8ebc632130 | ||
|
|
95c1483bb1 | ||
|
|
2486f162ed | ||
|
|
95a05a24e1 | ||
|
|
47f8e0599e | ||
|
|
15ebf4c37c |
4
.mvn/wrapper/maven-wrapper.properties
vendored
4
.mvn/wrapper/maven-wrapper.properties
vendored
@@ -1,2 +1,2 @@
|
||||
#Mon Jan 30 10:47:19 CET 2023
|
||||
distributionUrl=https\://repo.maven.apache.org/maven2/org/apache/maven/apache-maven/3.8.7/apache-maven-3.8.7-bin.zip
|
||||
#Mon Feb 20 11:59:26 CET 2023
|
||||
distributionUrl=https\://repo.maven.apache.org/maven2/org/apache/maven/apache-maven/3.9.0/apache-maven-3.9.0-bin.zip
|
||||
|
||||
6
pom.xml
6
pom.xml
@@ -5,7 +5,7 @@
|
||||
|
||||
<groupId>org.springframework.data</groupId>
|
||||
<artifactId>spring-data-mongodb-parent</artifactId>
|
||||
<version>4.0.2</version>
|
||||
<version>4.0.3</version>
|
||||
<packaging>pom</packaging>
|
||||
|
||||
<name>Spring Data MongoDB</name>
|
||||
@@ -15,7 +15,7 @@
|
||||
<parent>
|
||||
<groupId>org.springframework.data.build</groupId>
|
||||
<artifactId>spring-data-parent</artifactId>
|
||||
<version>3.0.2</version>
|
||||
<version>3.0.3</version>
|
||||
</parent>
|
||||
|
||||
<modules>
|
||||
@@ -26,7 +26,7 @@
|
||||
<properties>
|
||||
<project.type>multi</project.type>
|
||||
<dist.id>spring-data-mongodb</dist.id>
|
||||
<springdata.commons>3.0.2</springdata.commons>
|
||||
<springdata.commons>3.0.3</springdata.commons>
|
||||
<mongo>4.8.2</mongo>
|
||||
<mongo.reactivestreams>${mongo}</mongo.reactivestreams>
|
||||
<jmh.version>1.19</jmh.version>
|
||||
|
||||
@@ -7,7 +7,7 @@
|
||||
<parent>
|
||||
<groupId>org.springframework.data</groupId>
|
||||
<artifactId>spring-data-mongodb-parent</artifactId>
|
||||
<version>4.0.2</version>
|
||||
<version>4.0.3</version>
|
||||
<relativePath>../pom.xml</relativePath>
|
||||
</parent>
|
||||
|
||||
|
||||
@@ -15,7 +15,7 @@
|
||||
<parent>
|
||||
<groupId>org.springframework.data</groupId>
|
||||
<artifactId>spring-data-mongodb-parent</artifactId>
|
||||
<version>4.0.2</version>
|
||||
<version>4.0.3</version>
|
||||
<relativePath>../pom.xml</relativePath>
|
||||
</parent>
|
||||
|
||||
|
||||
@@ -13,7 +13,7 @@
|
||||
<parent>
|
||||
<groupId>org.springframework.data</groupId>
|
||||
<artifactId>spring-data-mongodb-parent</artifactId>
|
||||
<version>4.0.2</version>
|
||||
<version>4.0.3</version>
|
||||
<relativePath>../pom.xml</relativePath>
|
||||
</parent>
|
||||
|
||||
|
||||
@@ -283,6 +283,10 @@ class EntityOperations {
|
||||
* @see EntityProjectionIntrospector#introspect(Class, Class)
|
||||
*/
|
||||
public <M, D> EntityProjection<M, D> introspectProjection(Class<M> resultType, Class<D> entityType) {
|
||||
|
||||
if (!queryMapper.getMappingContext().hasPersistentEntityFor(entityType)) {
|
||||
return (EntityProjection) EntityProjection.nonProjecting(resultType);
|
||||
}
|
||||
return introspector.introspect(resultType, entityType);
|
||||
}
|
||||
|
||||
|
||||
@@ -2526,6 +2526,26 @@ public class MongoTemplateTests {
|
||||
assertThat(projection.getName()).isEqualTo("Walter");
|
||||
}
|
||||
|
||||
@Test // GH-4300
|
||||
public void findAndReplaceShouldAllowNativeDomainTypesAndReturnAProjection() {
|
||||
|
||||
MyPerson person = new MyPerson("Walter");
|
||||
person.address = new Address("TX", "Austin");
|
||||
template.save(person);
|
||||
|
||||
MyPerson previous = template.findAndReplace(query(where("name").is("Walter")),
|
||||
new org.bson.Document("name", "Heisenberg"), FindAndReplaceOptions.options(), org.bson.Document.class,
|
||||
"myPerson", MyPerson.class);
|
||||
|
||||
assertThat(previous).isNotNull();
|
||||
assertThat(previous.getAddress()).isEqualTo(person.address);
|
||||
|
||||
org.bson.Document loaded = template.execute(MyPerson.class, collection -> {
|
||||
return collection.find(new org.bson.Document("name", "Heisenberg")).first();
|
||||
});
|
||||
assertThat(loaded.get("_id")).isEqualTo(new ObjectId(person.id));
|
||||
}
|
||||
|
||||
@Test // DATAMONGO-407
|
||||
public void updatesShouldRetainTypeInformationEvenForCollections() {
|
||||
|
||||
|
||||
@@ -2312,6 +2312,17 @@ public class MongoTemplateUnitTests extends MongoOperationsUnitTests {
|
||||
.isEqualTo(new com.mongodb.client.model.TimeSeriesOptions("time_stamp").toString());
|
||||
}
|
||||
|
||||
@Test // GH-4300
|
||||
void findAndReplaceAllowsDocumentSourceType() {
|
||||
|
||||
template.findAndReplace(new Query(), new Document("spring", "data"), FindAndReplaceOptions.options().upsert(),
|
||||
Document.class, "coll-1", Person.class);
|
||||
|
||||
verify(db).getCollection(eq("coll-1"), eq(Document.class));
|
||||
verify(collection).findOneAndReplace((Bson) any(Bson.class), eq(new Document("spring", "data")),
|
||||
any(FindOneAndReplaceOptions.class));
|
||||
}
|
||||
|
||||
class AutogenerateableId {
|
||||
|
||||
@Id BigInteger id;
|
||||
|
||||
@@ -729,6 +729,32 @@ public class ReactiveMongoTemplateTests {
|
||||
}).verifyComplete();
|
||||
}
|
||||
|
||||
@Test // GH-4300
|
||||
public void findAndReplaceShouldAllowNativeDomainTypesAndReturnAProjection() {
|
||||
|
||||
MongoTemplateTests.MyPerson person = new MongoTemplateTests.MyPerson("Walter");
|
||||
person.address = new Address("TX", "Austin");
|
||||
template.save(person) //
|
||||
.as(StepVerifier::create) //
|
||||
.expectNextCount(1) //
|
||||
.verifyComplete();
|
||||
|
||||
template
|
||||
.findAndReplace(query(where("name").is("Walter")), new org.bson.Document("name", "Heisenberg"),
|
||||
FindAndReplaceOptions.options(), org.bson.Document.class, "myPerson", MongoTemplateTests.MyPerson.class)
|
||||
.as(StepVerifier::create) //
|
||||
.consumeNextWith(actual -> {
|
||||
assertThat(actual.getAddress()).isEqualTo(person.address);
|
||||
}).verifyComplete();
|
||||
|
||||
template.execute(MongoTemplateTests.MyPerson.class, collection -> {
|
||||
return collection.find(new org.bson.Document("name", "Heisenberg")).first();
|
||||
}).as(StepVerifier::create) //
|
||||
.consumeNextWith(loaded -> {
|
||||
assertThat(loaded.get("_id")).isEqualTo(new ObjectId(person.id));
|
||||
}).verifyComplete();
|
||||
}
|
||||
|
||||
@Test // DATAMONGO-1827
|
||||
void findAndReplaceShouldReplaceObjectReturingNew() {
|
||||
|
||||
|
||||
@@ -1,4 +1,4 @@
|
||||
Spring Data MongoDB 4.0.2 (2022.0.2)
|
||||
Spring Data MongoDB 4.0.3 (2022.0.3)
|
||||
Copyright (c) [2010-2019] Pivotal Software, Inc.
|
||||
|
||||
This product is licensed to you under the Apache License, Version 2.0 (the "License").
|
||||
@@ -42,5 +42,6 @@ conditions of the subcomponent's license, as noted in the LICENSE file.
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
Reference in New Issue
Block a user