Compare commits

..

6 Commits
4.0.2 ... 4.0.3

Author SHA1 Message Date
Mark Paluch
8ebc632130 Release version 4.0.3 (2022.0.3).
See #4293
2023-03-03 10:59:33 +01:00
Mark Paluch
95c1483bb1 Prepare 4.0.3 (2022.0.3).
See #4293
2023-03-03 10:59:17 +01:00
Christoph Strobl
2486f162ed Fix regression in findAndReplace when using native MongoDB types as domain value.
This commit fixes a regression that prevented native org.bson.Document to serve as source for a findAndReplaceOperation.

Closes: #4300
Original Pull Request: #4310
2023-03-02 10:02:31 +01:00
Mark Paluch
95a05a24e1 Upgrade to Maven Wrapper 3.9.0.
See #4298
2023-02-20 11:59:26 +01:00
Mark Paluch
47f8e0599e After release cleanups.
See #4274
2023-02-17 11:02:27 +01:00
Mark Paluch
15ebf4c37c Prepare next development iteration.
See #4274
2023-02-17 11:02:25 +01:00
10 changed files with 71 additions and 9 deletions

View File

@@ -1,2 +1,2 @@
#Mon Jan 30 10:47:19 CET 2023 #Mon Feb 20 11:59:26 CET 2023
distributionUrl=https\://repo.maven.apache.org/maven2/org/apache/maven/apache-maven/3.8.7/apache-maven-3.8.7-bin.zip distributionUrl=https\://repo.maven.apache.org/maven2/org/apache/maven/apache-maven/3.9.0/apache-maven-3.9.0-bin.zip

View File

@@ -5,7 +5,7 @@
<groupId>org.springframework.data</groupId> <groupId>org.springframework.data</groupId>
<artifactId>spring-data-mongodb-parent</artifactId> <artifactId>spring-data-mongodb-parent</artifactId>
<version>4.0.2</version> <version>4.0.3</version>
<packaging>pom</packaging> <packaging>pom</packaging>
<name>Spring Data MongoDB</name> <name>Spring Data MongoDB</name>
@@ -15,7 +15,7 @@
<parent> <parent>
<groupId>org.springframework.data.build</groupId> <groupId>org.springframework.data.build</groupId>
<artifactId>spring-data-parent</artifactId> <artifactId>spring-data-parent</artifactId>
<version>3.0.2</version> <version>3.0.3</version>
</parent> </parent>
<modules> <modules>
@@ -26,7 +26,7 @@
<properties> <properties>
<project.type>multi</project.type> <project.type>multi</project.type>
<dist.id>spring-data-mongodb</dist.id> <dist.id>spring-data-mongodb</dist.id>
<springdata.commons>3.0.2</springdata.commons> <springdata.commons>3.0.3</springdata.commons>
<mongo>4.8.2</mongo> <mongo>4.8.2</mongo>
<mongo.reactivestreams>${mongo}</mongo.reactivestreams> <mongo.reactivestreams>${mongo}</mongo.reactivestreams>
<jmh.version>1.19</jmh.version> <jmh.version>1.19</jmh.version>

View File

@@ -7,7 +7,7 @@
<parent> <parent>
<groupId>org.springframework.data</groupId> <groupId>org.springframework.data</groupId>
<artifactId>spring-data-mongodb-parent</artifactId> <artifactId>spring-data-mongodb-parent</artifactId>
<version>4.0.2</version> <version>4.0.3</version>
<relativePath>../pom.xml</relativePath> <relativePath>../pom.xml</relativePath>
</parent> </parent>

View File

@@ -15,7 +15,7 @@
<parent> <parent>
<groupId>org.springframework.data</groupId> <groupId>org.springframework.data</groupId>
<artifactId>spring-data-mongodb-parent</artifactId> <artifactId>spring-data-mongodb-parent</artifactId>
<version>4.0.2</version> <version>4.0.3</version>
<relativePath>../pom.xml</relativePath> <relativePath>../pom.xml</relativePath>
</parent> </parent>

View File

@@ -13,7 +13,7 @@
<parent> <parent>
<groupId>org.springframework.data</groupId> <groupId>org.springframework.data</groupId>
<artifactId>spring-data-mongodb-parent</artifactId> <artifactId>spring-data-mongodb-parent</artifactId>
<version>4.0.2</version> <version>4.0.3</version>
<relativePath>../pom.xml</relativePath> <relativePath>../pom.xml</relativePath>
</parent> </parent>

View File

@@ -283,6 +283,10 @@ class EntityOperations {
* @see EntityProjectionIntrospector#introspect(Class, Class) * @see EntityProjectionIntrospector#introspect(Class, Class)
*/ */
public <M, D> EntityProjection<M, D> introspectProjection(Class<M> resultType, Class<D> entityType) { public <M, D> EntityProjection<M, D> introspectProjection(Class<M> resultType, Class<D> entityType) {
if (!queryMapper.getMappingContext().hasPersistentEntityFor(entityType)) {
return (EntityProjection) EntityProjection.nonProjecting(resultType);
}
return introspector.introspect(resultType, entityType); return introspector.introspect(resultType, entityType);
} }

View File

@@ -2526,6 +2526,26 @@ public class MongoTemplateTests {
assertThat(projection.getName()).isEqualTo("Walter"); 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 @Test // DATAMONGO-407
public void updatesShouldRetainTypeInformationEvenForCollections() { public void updatesShouldRetainTypeInformationEvenForCollections() {

View File

@@ -2312,6 +2312,17 @@ public class MongoTemplateUnitTests extends MongoOperationsUnitTests {
.isEqualTo(new com.mongodb.client.model.TimeSeriesOptions("time_stamp").toString()); .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 { class AutogenerateableId {
@Id BigInteger id; @Id BigInteger id;

View File

@@ -729,6 +729,32 @@ public class ReactiveMongoTemplateTests {
}).verifyComplete(); }).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 @Test // DATAMONGO-1827
void findAndReplaceShouldReplaceObjectReturingNew() { void findAndReplaceShouldReplaceObjectReturingNew() {

View File

@@ -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. Copyright (c) [2010-2019] Pivotal Software, Inc.
This product is licensed to you under the Apache License, Version 2.0 (the "License"). 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.