Compare commits

...

35 Commits

Author SHA1 Message Date
Mark Paluch
47f1b53ca0 DATAMONGO-2646 - Release version 2.2.12 (Moore SR12). 2020-12-09 09:37:36 +01:00
Mark Paluch
c10d92a0c3 DATAMONGO-2646 - Prepare 2.2.12 (Moore SR12). 2020-12-09 09:37:07 +01:00
Mark Paluch
1f18220dfa DATAMONGO-2646 - Updated changelog. 2020-12-09 09:37:03 +01:00
Mark Paluch
a4a2d6e29c DATAMONGO-2663 - Document Spring Data to MongoDB compatibility.
Original Pull Request: #895
2020-12-07 14:39:49 +01:00
Mark Paluch
786fbba428 DATAMONGO-2648 - Updated changelog. 2020-11-11 12:34:39 +01:00
Mark Paluch
8743270035 DATAMONGO-2639 - Updated changelog. 2020-10-28 16:28:00 +01:00
Mark Paluch
73d9b2e585 DATAMONGO-2625 - Updated changelog. 2020-10-28 15:03:04 +01:00
Mark Paluch
092c7e7260 DATAMONGO-2624 - After release cleanups. 2020-10-28 12:06:21 +01:00
Mark Paluch
8b3761656f DATAMONGO-2624 - Prepare next development iteration. 2020-10-28 12:06:18 +01:00
Mark Paluch
c89f707966 DATAMONGO-2624 - Release version 2.2.11 (Moore SR11). 2020-10-28 11:44:36 +01:00
Mark Paluch
b1764160c5 DATAMONGO-2624 - Prepare 2.2.11 (Moore SR11). 2020-10-28 11:44:06 +01:00
Mark Paluch
7e1e33d51f DATAMONGO-2624 - Updated changelog. 2020-10-28 11:43:53 +01:00
Mark Paluch
2a81418738 DATAMONGO-2641 - Updated changelog. 2020-10-28 11:32:30 +01:00
Robin Dupret
f72a961bb4 DATAMONGO-2638 - Fix list item rendering in reference documentation.
Original Pull Request: #885
2020-10-27 13:33:40 +01:00
LiangYong
e398bf8a24 DATAMONGO-2638 - Fix aggregation input parameter syntax in reference documentation.
Original Pull Request: #881
2020-10-27 13:33:36 +01:00
Christoph Strobl
7787a5cf0e DATAMONGO-2626 - Updated changelog. 2020-10-14 14:51:52 +02:00
Mark Paluch
0786969ef2 DATAMONGO-2616 - Polishing.
Reformat code. Merge if-statements.

Original pull request: #889.
2020-10-07 11:36:01 +02:00
Christoph Strobl
98040ad44e DATAMONGO-2616 - Short circuit id value assignment in MongoConverter.
Original pull request: #889.
2020-10-07 11:36:01 +02:00
Christoph Strobl
ad4ab65a9f DATAMONGO-2633 - Fix json parsing of nested arrays in ParameterBindingDocumentCodec.
Original pull request: #888.
2020-10-05 15:42:07 +02:00
Mark Paluch
e05113ea27 DATAMONGO-2608 - Updated changelog. 2020-09-16 14:12:07 +02:00
Mark Paluch
c78898edf7 DATAMONGO-2609 - Updated changelog. 2020-09-16 12:16:36 +02:00
Mark Paluch
9f6be1f471 DATAMONGO-2593 - After release cleanups. 2020-09-16 11:19:26 +02:00
Mark Paluch
f8a48637ec DATAMONGO-2593 - Prepare next development iteration. 2020-09-16 11:19:23 +02:00
Mark Paluch
df73c567ce DATAMONGO-2593 - Release version 2.2.10 (Moore SR10). 2020-09-16 10:53:21 +02:00
Mark Paluch
47ce8258b0 DATAMONGO-2593 - Prepare 2.2.10 (Moore SR10). 2020-09-16 10:52:53 +02:00
Mark Paluch
e523d9a1cb DATAMONGO-2593 - Updated changelog. 2020-09-16 10:52:37 +02:00
Mark Paluch
d65632c097 DATAMONGO-2592 - Updated changelog. 2020-09-16 10:39:00 +02:00
Christoph Strobl
29bf4f72f3 DATAMONGO-2618 - Fix visibility of ReplaceRootDocumentOperation. 2020-09-14 13:46:20 +02:00
Michal Kurcius
ee79b9939b DATAMONGO-2613 - Fix single element ArrayJsonSchemaObject to document mapping.
Now toDocument calls toDocument on items correctly.

Original Pull Request: #883
2020-08-20 09:13:09 +02:00
Mark Paluch
156ec5b441 DATAMONGO-2594 - Updated changelog. 2020-08-12 13:25:53 +02:00
Mark Paluch
931028b43e DATAMONGO-2579 - Updated changelog. 2020-08-12 12:01:24 +02:00
Mark Paluch
687c4d35ed DATAMONGO-2599 - Eagerly consider enum types as simple types.
MongoSimpleTypes now eagerly checks if a type is a simple one to avoid PersistentEntity registration for ChronoUnit.
2020-07-30 16:36:37 +02:00
Mark Paluch
71ac036dc3 DATAMONGO-2568 - Updated changelog. 2020-07-22 10:38:03 +02:00
Mark Paluch
da3ab42f10 DATAMONGO-2567 - After release cleanups. 2020-07-22 10:07:19 +02:00
Mark Paluch
537fc1caad DATAMONGO-2567 - Prepare next development iteration. 2020-07-22 10:07:16 +02:00
17 changed files with 246 additions and 24 deletions

View File

@@ -5,7 +5,7 @@
<groupId>org.springframework.data</groupId>
<artifactId>spring-data-mongodb-parent</artifactId>
<version>2.2.9.RELEASE</version>
<version>2.2.12.RELEASE</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>2.2.9.RELEASE</version>
<version>2.2.12.RELEASE</version>
</parent>
<modules>
@@ -26,7 +26,7 @@
<properties>
<project.type>multi</project.type>
<dist.id>spring-data-mongodb</dist.id>
<springdata.commons>2.2.9.RELEASE</springdata.commons>
<springdata.commons>2.2.12.RELEASE</springdata.commons>
<mongo>3.11.2</mongo>
<mongo.reactivestreams>1.12.0</mongo.reactivestreams>
<jmh.version>1.19</jmh.version>

View File

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

View File

@@ -14,7 +14,7 @@
<parent>
<groupId>org.springframework.data</groupId>
<artifactId>spring-data-mongodb-parent</artifactId>
<version>2.2.9.RELEASE</version>
<version>2.2.12.RELEASE</version>
<relativePath>../pom.xml</relativePath>
</parent>

View File

@@ -11,7 +11,7 @@
<parent>
<groupId>org.springframework.data</groupId>
<artifactId>spring-data-mongodb-parent</artifactId>
<version>2.2.9.RELEASE</version>
<version>2.2.12.RELEASE</version>
<relativePath>../pom.xml</relativePath>
</parent>

View File

@@ -155,7 +155,7 @@ public class ReplaceRootOperation implements FieldsExposingAggregationOperation
*
* @author Mark Paluch
*/
static class ReplaceRootDocumentOperation extends ReplaceRootOperation {
public static class ReplaceRootDocumentOperation extends ReplaceRootOperation {
private final static ReplacementDocument EMPTY = new ReplacementDocument();
private final ReplacementDocument current;

View File

@@ -127,8 +127,8 @@ public interface MongoConverter
@Nullable
default Object convertId(@Nullable Object id, Class<?> targetType) {
if (id == null) {
return null;
if (id == null || ClassUtils.isAssignableValue(targetType, id)) {
return id;
}
if (ClassUtils.isAssignable(ObjectId.class, targetType)) {

View File

@@ -47,6 +47,7 @@ import com.mongodb.client.model.geojson.Polygon;
*
* @author Oliver Gierke
* @author Christoph Strobl
* @author Mark Paluch
*/
public abstract class MongoSimpleTypes {
@@ -107,6 +108,10 @@ public abstract class MongoSimpleTypes {
@Override
public boolean isSimpleType(Class<?> type) {
if (type.isEnum()) {
return true;
}
if (type.getName().startsWith("java.time")) {
return false;
}

View File

@@ -41,6 +41,7 @@ import org.springframework.util.StringUtils;
*
* @author Christoph Strobl
* @author Mark Paluch
* @author Michał Kurcius
* @since 2.1
*/
public class TypedJsonSchemaObject extends UntypedJsonSchemaObject {
@@ -1203,7 +1204,7 @@ public class TypedJsonSchemaObject extends UntypedJsonSchemaObject {
Document doc = new Document(super.toDocument());
if (!CollectionUtils.isEmpty(items)) {
doc.append("items", items.size() == 1 ? items.iterator().next()
doc.append("items", items.size() == 1 ? items.iterator().next().toDocument()
: items.stream().map(JsonSchemaObject::toDocument).collect(Collectors.toList()));
}

View File

@@ -336,15 +336,7 @@ public class ParameterBindingDocumentCodec implements CollectibleCodec<Document>
reader.readStartArray();
List<Object> list = new ArrayList<>();
while (reader.readBsonType() != BsonType.END_OF_DOCUMENT) {
// Spring Data Customization START
Object listValue = readValue(reader, decoderContext);
if (listValue instanceof Collection) {
list.addAll((Collection) listValue);
break;
}
list.add(listValue);
// Spring Data Customization END
list.add(readValue(reader, decoderContext));
}
reader.readEndArray();
return list;

View File

@@ -17,6 +17,7 @@ package org.springframework.data.mongodb.core.mapping;
import static org.assertj.core.api.Assertions.*;
import java.time.temporal.ChronoUnit;
import java.util.AbstractMap;
import java.util.Collections;
import java.util.Locale;
@@ -158,6 +159,18 @@ public class MongoMappingContextUnitTests {
.withMessageContaining("score").withMessageContaining("Float").withMessageContaining("Double");
}
@Test // DATAMONGO-2599
public void shouldNotCreateEntityForEnum() {
MongoMappingContext context = new MongoMappingContext();
BasicMongoPersistentEntity<?> entity = context.getRequiredPersistentEntity(ClassWithChronoUnit.class);
assertThat(entity.getPersistentProperty("unit").isEntity()).isFalse();
assertThat(context.hasPersistentEntityFor(ChronoUnit.class)).isFalse();
assertThat(context.getPersistentEntity(ChronoUnit.class)).isNull();
}
public class SampleClass {
Map<String, SampleClass> children;
@@ -224,4 +237,9 @@ public class MongoMappingContextUnitTests {
@TextScore Locale score;
}
class ClassWithChronoUnit {
ChronoUnit unit;
}
}

View File

@@ -39,6 +39,7 @@ import org.springframework.data.domain.Range.*;
*
* @author Christoph Strobl
* @author Mark Paluch
* @author Michał Kurcius
*/
public class JsonSchemaObjectUnitTests {
@@ -267,6 +268,13 @@ public class JsonSchemaObjectUnitTests {
.append("items", Arrays.asList(new Document("type", "string"), new Document("type", "boolean"))));
}
@Test // DATAMONGO-2613
public void arrayObjectShouldRenderItemsCorrectlyAsObjectIfContainsOnlyOneElement() {
assertThat(array().items(Collections.singletonList(string())).toDocument()).isEqualTo(new Document("type", "array")
.append("items", new Document("type", "string")));
}
@Test // DATAMONGO-1835
public void arrayObjectShouldRenderMaxItemsCorrectly() {

View File

@@ -349,6 +349,15 @@ public class ParameterBindingJsonReaderUnitTests {
.isEqualTo(Document.parse("{ $and: [{'fieldA': {$in: [/ABC.*/, /CDE.*F/]}}, {'fieldB': {$ne: null}}]}"));
}
@Test // DATAMONGO-2633
public void shouldParseNestedArrays() {
Document target = parse("{ 'stores.location' : { $geoWithin: { $centerSphere: [ [ ?0, 48.799029 ] , ?1 ] } } }",
1.948516D, 0.004D);
assertThat(target).isEqualTo(Document
.parse("{ 'stores.location' : { $geoWithin: { $centerSphere: [ [ 1.948516, 48.799029 ] , 0.004 ] } } }"));
}
private static Document parse(String json, Object... args) {
ParameterBindingJsonReader reader = new ParameterBindingJsonReader(json, args);

View File

@@ -41,7 +41,62 @@ The starting point for learning about MongoDB is https://www.mongodb.org/[www.mo
The Spring Data MongoDB 2.x binaries require JDK level 8.0 and above and https://spring.io/docs[Spring Framework] {springVersion} and above.
In terms of document stores, you need at least version 2.6 of https://www.mongodb.org/[MongoDB].
In terms of document stores, you need at least version 3.6 of https://www.mongodb.org/[MongoDB], though we recommend a more recent version.
[[compatibility.matrix]]
=== Compatibility Matrix
The following compatibility matrix summarizes Spring Data versions to MongoDB driver/database versions.
Database versions show the highest supported server version that pass the Spring Data test suite.
You can use newer server versions unless your application uses functionality that is affected by <<compatibility.changes,changes in the MongoDB server>>.
[cols="h,m,m,m", options="header"]
|===
|Spring Data Release Train
|Spring Data MongoDB
|Driver Version
|Server Version
|2021.0
|3.2.x
|4.1.x
|4.4.x
|2020.0
|3.1.x
|4.1.x
|4.4.x
|Neumann
|3.0.x
|4.0.x
|4.4.x
|Moore
|2.2.x
|3.11.x/Reactive Streams 1.12.x
|4.2.x
|Lovelace
|2.1.x
|3.8.x/Reactive Streams 1.9.x
|4.0.x
|===
[[compatibility.changes]]
[[compatibility.changes-4.4]]
==== Relevant Changes in MongoDB 4.4
* Fields list must not contain text search score property when no `$text` criteria present. See also https://docs.mongodb.com/manual/reference/operator/query/text/[`$text` operator]
* Sort must not be an empty document when running map reduce.
[[compatibility.changes-4.2]]
==== Relevant Changes in MongoDB 4.2
* Removal of `geoNear` command. See also https://docs.mongodb.com/manual/release-notes/4.2-compatibility/#remove-support-for-the-geonear-command[Removal of `geoNear`]
* Removal of `eval` command. See also https://docs.mongodb.com/manual/release-notes/4.2-compatibility/#remove-support-for-the-eval-command[Removal of `eval`]
[[get-started:help]]
== Additional Help Resources

View File

@@ -18,10 +18,10 @@ public interface PersonRepository extends CrudReppsitory<Person, String> {
@Aggregation("{ $group: { _id : $lastname, names : { $addToSet : $firstname } } }")
List<PersonAggregate> groupByLastnameAndFirstnames(Sort sort); <2>
@Aggregation("{ $group: { _id : $lastname, names : { $addToSet : $?0 } } }")
@Aggregation("{ $group: { _id : $lastname, names : { $addToSet : ?0 } } }")
List<PersonAggregate> groupByLastnameAnd(String property); <3>
@Aggregation("{ $group: { _id : $lastname, names : { $addToSet : $?0 } } }")
@Aggregation("{ $group: { _id : $lastname, names : { $addToSet : ?0 } } }")
List<PersonAggregate> groupByLastnameAnd(String property, Pageable page); <4>
@Aggregation("{ $group : { _id : null, total : { $sum : $age } } }")

View File

@@ -27,7 +27,7 @@ First, you need to set up a running MongoDB server. Refer to the https://docs.mo
To create a Spring project in STS:
. Go to File -> New -> Spring Template Project -> Simple Spring Utility Project, and press Yes when prompted. Then enter a project and a package name, such as `org.spring.mongodb.example`.
.Add the following to the pom.xml files `dependencies` element:
. Add the following to the pom.xml files `dependencies` element:
+
[source,xml,subs="+attributes"]
----

View File

@@ -1,6 +1,123 @@
Spring Data MongoDB Changelog
=============================
Changes in version 2.2.12.RELEASE (2020-12-09)
----------------------------------------------
* DATAMONGO-2663 - Document Spring Data to MongoDB compatibility.
* DATAMONGO-2646 - Release 2.2.12 (Moore SR12).
Changes in version 3.1.1 (2020-11-11)
-------------------------------------
* DATAMONGO-2648 - Release 3.1.1 (2020.0.1).
* DATAMONGO-2644 - Invalid reference '_id'! Error In spring data mongodb.
* DATAMONGO-2635 - Enums Don't Properly Serialize In Aggregation Pipeline Facet.
Changes in version 3.1.0 (2020-10-28)
-------------------------------------
* DATAMONGO-2642 - Upgrade to MongoDB Driver 4.1.1.
* DATAMONGO-2639 - Release 3.1 GA (2020.0.0).
* DATAMONGO-2638 - Fix documentation issues.
Changes in version 3.0.5.RELEASE (2020-10-28)
---------------------------------------------
* DATAMONGO-2643 - Adopt to AssertJ API changes.
* DATAMONGO-2638 - Fix documentation issues.
* DATAMONGO-2633 - @Query annotation does not support $centerSphere.
* DATAMONGO-2625 - Release 3.0.5 (Neumann SR5).
Changes in version 2.2.11.RELEASE (2020-10-28)
----------------------------------------------
* DATAMONGO-2638 - Fix documentation issues.
* DATAMONGO-2633 - @Query annotation does not support $centerSphere.
* DATAMONGO-2624 - Release 2.2.11 (Moore SR11).
Changes in version 2.1.21.RELEASE (2020-10-28)
----------------------------------------------
* DATAMONGO-2641 - Release 2.1.21 (Lovelace SR21).
Changes in version 3.1.0-RC2 (2020-10-14)
-----------------------------------------
* DATAMONGO-2633 - @Query annotation does not support $centerSphere.
* DATAMONGO-2630 - Add support for suspend repository query methods returning List<T>.
* DATAMONGO-2626 - Release 3.1 RC2 (2020.0.0).
* DATAMONGO-2623 - Add support for custom Aggregation expressions.
* DATAMONGO-2622 - Add support for $unionWith aggregation.
* DATAMONGO-2596 - Introduce extension to render KProperty/KPropertyPath as property path.
* DATAMONGO-2294 - Support multiple parameters for query field projections.
Changes in version 3.1.0-RC1 (2020-09-16)
-----------------------------------------
* DATAMONGO-2621 - Adapt to changed array assertions in AssertJ.
* DATAMONGO-2618 - ReplaceRootDocumentOperation not visible.
* DATAMONGO-2613 - ArrayJsonSchemaObject incorrectly mapped to Document.
* DATAMONGO-2608 - Release 3.1 RC1 (2020.0.0).
Changes in version 3.0.4.RELEASE (2020-09-16)
---------------------------------------------
* DATAMONGO-2618 - ReplaceRootDocumentOperation not visible.
* DATAMONGO-2613 - ArrayJsonSchemaObject incorrectly mapped to Document.
* DATAMONGO-2609 - Release 3.0.4 (Neumann SR4).
Changes in version 2.2.10.RELEASE (2020-09-16)
----------------------------------------------
* DATAMONGO-2618 - ReplaceRootDocumentOperation not visible.
* DATAMONGO-2613 - ArrayJsonSchemaObject incorrectly mapped to Document.
* DATAMONGO-2599 - Ambiguous field mapping detected for enum java.time.temporal.ChronoUnit.
* DATAMONGO-2593 - Release 2.2.10 (Moore SR10).
Changes in version 2.1.20.RELEASE (2020-09-16)
----------------------------------------------
* DATAMONGO-2618 - ReplaceRootDocumentOperation not visible.
* DATAMONGO-2613 - ArrayJsonSchemaObject incorrectly mapped to Document.
* DATAMONGO-2592 - Release 2.1.20 (Lovelace SR20).
Changes in version 3.0.3.RELEASE (2020-08-12)
---------------------------------------------
* DATAMONGO-2601 - Consider Unit a void type in Coroutine repositories.
* DATAMONGO-2599 - Ambiguous field mapping detected for enum java.time.temporal.ChronoUnit.
* DATAMONGO-2598 - Wording changes.
* DATAMONGO-2594 - Release 3.0.3 (Neumann SR3).
Changes in version 3.1.0-M2 (2020-08-12)
----------------------------------------
* DATAMONGO-2603 - Adopt to Reactor 3.4 changes.
* DATAMONGO-2602 - Upgrade MongoDB drivers to 4.1.0.
* DATAMONGO-2601 - Consider Unit a void type in Coroutine repositories.
* DATAMONGO-2599 - Ambiguous field mapping detected for enum java.time.temporal.ChronoUnit.
* DATAMONGO-2598 - Wording changes.
* DATAMONGO-2591 - Upgrade MongoDB drivers to 4.1.0-rc0.
* DATAMONGO-2586 - Add support for reactive auditing.
* DATAMONGO-2579 - Release 3.1 M2 (2020.0.0).
* DATAMONGO-2571 - regex expression included "/" character can't be parsed in the stage of aggregation annotation.
* DATAMONGO-2536 - Add option to discard results on $out and $merge.
* DATAMONGO-2490 - @DBRef fetched without ClientSession when using Spring Transactions.
* DATAMONGO-1894 - Use reactive subscriber context for SpEL evaluation in query execution.
* DATAMONGO-1836 - Add support for hint option to aggregation.
Changes in version 3.0.2.RELEASE (2020-07-22)
---------------------------------------------
* DATAMONGO-2589 - Upgrade to MongoDB Driver 4.0.5.
* DATAMONGO-2572 - Remove usage of Oppressive Language.
* DATAMONGO-2571 - regex expression included "/" character can't be parsed in the stage of aggregation annotation.
* DATAMONGO-2570 - Avoiding unintentional unboxing.
* DATAMONGO-2568 - Release 3.0.2 (Neumann SR2).
* DATAMONGO-2536 - Add option to discard results on $out and $merge.
* DATAMONGO-2490 - @DBRef fetched without ClientSession when using Spring Transactions.
Changes in version 2.2.9.RELEASE (2020-07-22)
---------------------------------------------
* DATAMONGO-2572 - Remove usage of Oppressive Language.
@@ -3087,6 +3204,20 @@ Repository

View File

@@ -1,4 +1,4 @@
Spring Data MongoDB 2.2.9 (Moore SR9)
Spring Data MongoDB 2.2.12 (Moore SR12)
Copyright (c) [2010-2019] Pivotal Software, Inc.
This product is licensed to you under the Apache License, Version 2.0 (the "License").
@@ -15,3 +15,6 @@ conditions of the subcomponent's license, as noted in the LICENSE file.