Compare commits
27 Commits
3.0.4.RELE
...
3.0.6.RELE
| Author | SHA1 | Date | |
|---|---|---|---|
|
|
ec0fe6f994 | ||
|
|
d3d690b908 | ||
|
|
b98b5125f1 | ||
|
|
d68bd4b44a | ||
|
|
a73ae9a1a5 | ||
|
|
ac3c578e93 | ||
|
|
9872f8cb07 | ||
|
|
1b1ab2c495 | ||
|
|
6554274dde | ||
|
|
34f91acbfe | ||
|
|
8e7d508cfe | ||
|
|
04dd78cb36 | ||
|
|
52c554cfe1 | ||
|
|
c1bb8c4ba5 | ||
|
|
ed9a367bb8 | ||
|
|
b88ce46239 | ||
|
|
42ec94d321 | ||
|
|
53f35e185f | ||
|
|
e08bfd253c | ||
|
|
caaafa275d | ||
|
|
1f082abc7f | ||
|
|
df77fcc19d | ||
|
|
007b965673 | ||
|
|
1b9680cece | ||
|
|
13f1d21919 | ||
|
|
4c10bf30bc | ||
|
|
8f78d0e0d8 |
6
pom.xml
6
pom.xml
@@ -5,7 +5,7 @@
|
||||
|
||||
<groupId>org.springframework.data</groupId>
|
||||
<artifactId>spring-data-mongodb-parent</artifactId>
|
||||
<version>3.0.4.RELEASE</version>
|
||||
<version>3.0.6.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.3.4.RELEASE</version>
|
||||
<version>2.3.6.RELEASE</version>
|
||||
</parent>
|
||||
|
||||
<modules>
|
||||
@@ -26,7 +26,7 @@
|
||||
<properties>
|
||||
<project.type>multi</project.type>
|
||||
<dist.id>spring-data-mongodb</dist.id>
|
||||
<springdata.commons>2.3.4.RELEASE</springdata.commons>
|
||||
<springdata.commons>2.3.6.RELEASE</springdata.commons>
|
||||
<mongo>4.0.5</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>3.0.4.RELEASE</version>
|
||||
<version>3.0.6.RELEASE</version>
|
||||
<relativePath>../pom.xml</relativePath>
|
||||
</parent>
|
||||
|
||||
|
||||
@@ -14,7 +14,7 @@
|
||||
<parent>
|
||||
<groupId>org.springframework.data</groupId>
|
||||
<artifactId>spring-data-mongodb-parent</artifactId>
|
||||
<version>3.0.4.RELEASE</version>
|
||||
<version>3.0.6.RELEASE</version>
|
||||
<relativePath>../pom.xml</relativePath>
|
||||
</parent>
|
||||
|
||||
|
||||
@@ -11,7 +11,7 @@
|
||||
<parent>
|
||||
<groupId>org.springframework.data</groupId>
|
||||
<artifactId>spring-data-mongodb-parent</artifactId>
|
||||
<version>3.0.4.RELEASE</version>
|
||||
<version>3.0.6.RELEASE</version>
|
||||
<relativePath>../pom.xml</relativePath>
|
||||
</parent>
|
||||
|
||||
|
||||
@@ -264,7 +264,7 @@ public class ProjectionOperation implements FieldsExposingAggregationOperation {
|
||||
return new Document(getOperator(), fieldObject);
|
||||
}
|
||||
|
||||
/*
|
||||
/*
|
||||
* (non-Javadoc)
|
||||
* @see org.springframework.data.mongodb.core.aggregation.AggregationOperation#getOperator()
|
||||
*/
|
||||
@@ -1450,6 +1450,14 @@ public class ProjectionOperation implements FieldsExposingAggregationOperation {
|
||||
return field.getTarget();
|
||||
}
|
||||
|
||||
if (field.getTarget().equals(Fields.UNDERSCORE_ID)) {
|
||||
try {
|
||||
return context.getReference(field).getReferenceValue();
|
||||
} catch (java.lang.IllegalArgumentException e) {
|
||||
return Fields.UNDERSCORE_ID_REF;
|
||||
}
|
||||
}
|
||||
|
||||
// check whether referenced field exists in the context
|
||||
return context.getReference(field).getReferenceValue();
|
||||
|
||||
|
||||
@@ -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)) {
|
||||
|
||||
@@ -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;
|
||||
|
||||
@@ -25,7 +25,7 @@ import kotlin.reflect.KProperty1
|
||||
* @since 2.2
|
||||
*/
|
||||
class KPropertyPath<T, U>(
|
||||
internal val parent: KProperty<U>,
|
||||
internal val parent: KProperty<U?>,
|
||||
internal val child: KProperty1<U, T>
|
||||
) : KProperty<T> by child
|
||||
|
||||
@@ -50,7 +50,8 @@ internal fun asString(property: KProperty<*>): String {
|
||||
* Book::author / Author::name isEqualTo "Herman Melville"
|
||||
* ```
|
||||
* @author Tjeu Kayim
|
||||
* @author Yoann de Martino
|
||||
* @since 2.2
|
||||
*/
|
||||
operator fun <T, U> KProperty<T>.div(other: KProperty1<T, U>) =
|
||||
operator fun <T, U> KProperty<T?>.div(other: KProperty1<T, U>) =
|
||||
KPropertyPath(this, other)
|
||||
|
||||
@@ -29,6 +29,11 @@ import org.bson.Document;
|
||||
import org.junit.jupiter.api.Test;
|
||||
import org.springframework.data.domain.Sort.Direction;
|
||||
import org.springframework.data.mongodb.core.aggregation.ConditionalOperators.Cond;
|
||||
import org.springframework.data.mongodb.core.aggregation.ProjectionOperationUnitTests.BookWithFieldAnnotation;
|
||||
import org.springframework.data.mongodb.core.convert.MappingMongoConverter;
|
||||
import org.springframework.data.mongodb.core.convert.NoOpDbRefResolver;
|
||||
import org.springframework.data.mongodb.core.convert.QueryMapper;
|
||||
import org.springframework.data.mongodb.core.mapping.MongoMappingContext;
|
||||
import org.springframework.data.mongodb.core.query.Criteria;
|
||||
|
||||
/**
|
||||
@@ -582,6 +587,17 @@ public class AggregationUnitTests {
|
||||
"{\"attributeRecordArrays\": {\"$reduce\": {\"input\": \"$attributeRecordArrays\", \"initialValue\": [], \"in\": {\"$concatArrays\": [\"$$value\", \"$$this\"]}}}}"));
|
||||
}
|
||||
|
||||
@Test // DATAMONGO-2644
|
||||
void projectOnIdIsAlwaysValid() {
|
||||
|
||||
MongoMappingContext mappingContext = new MongoMappingContext();
|
||||
Document target = new Aggregation(bucket("start"), project("_id")).toDocument("collection-1",
|
||||
new RelaxedTypeBasedAggregationOperationContext(BookWithFieldAnnotation.class, mappingContext,
|
||||
new QueryMapper(new MappingMongoConverter(NoOpDbRefResolver.INSTANCE, mappingContext))));
|
||||
|
||||
assertThat(extractPipelineElement(target, 1, "$project")).isEqualTo(Document.parse(" { \"_id\" : \"$_id\" }"));
|
||||
}
|
||||
|
||||
private Document extractPipelineElement(Document agg, int index, String operation) {
|
||||
|
||||
List<Document> pipeline = (List<Document>) agg.get("pipeline");
|
||||
|
||||
@@ -1884,8 +1884,7 @@ public class MappingMongoConverterUnitTests {
|
||||
|
||||
WithNestedLists result = converter.read(WithNestedLists.class, document);
|
||||
|
||||
assertThat(result.nestedFloats).hasSize(1);
|
||||
assertThat(result.nestedFloats).isEqualTo(new float[][][] { { { 1.0f, 2.0f } } });
|
||||
assertThat(result.nestedFloats).hasDimensions(1, 1).isEqualTo(new float[][][] { { { 1.0f, 2.0f } } });
|
||||
}
|
||||
|
||||
@Test // DATAMONGO-1992
|
||||
|
||||
@@ -349,6 +349,15 @@ class ParameterBindingJsonReaderUnitTests {
|
||||
.isEqualTo(Document.parse("{ $and: [{'fieldA': {$in: [/ABC.*/, /CDE.*F/]}}, {'fieldB': {$ne: null}}]}"));
|
||||
}
|
||||
|
||||
@Test // DATAMONGO-2633
|
||||
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);
|
||||
|
||||
@@ -20,6 +20,7 @@ import org.junit.Test
|
||||
|
||||
/**
|
||||
* @author Tjeu Kayim
|
||||
* @author Yoann de Martino
|
||||
*/
|
||||
class KPropertyPathTests {
|
||||
|
||||
@@ -60,6 +61,15 @@ class KPropertyPathTests {
|
||||
assertThat(property).isEqualTo("entity.book.author.name")
|
||||
}
|
||||
|
||||
@Test // DATAMONGO-2661
|
||||
fun `Convert nullable KProperty to field name`() {
|
||||
class Cat(val name: String)
|
||||
class Owner(val cat: Cat?)
|
||||
|
||||
val property = asString(Owner::cat / Cat::name)
|
||||
assertThat(property).isEqualTo("cat.name")
|
||||
}
|
||||
|
||||
class Book(val title: String, val author: Author)
|
||||
class Author(val name: String)
|
||||
}
|
||||
|
||||
@@ -41,7 +41,62 @@ The starting point for learning about MongoDB is https://www.mongodb.org/[www.mo
|
||||
|
||||
The Spring Data MongoDB 3.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
|
||||
|
||||
@@ -17,10 +17,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 } } }")
|
||||
|
||||
@@ -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"]
|
||||
----
|
||||
|
||||
@@ -1,6 +1,73 @@
|
||||
Spring Data MongoDB Changelog
|
||||
=============================
|
||||
|
||||
Changes in version 3.0.6.RELEASE (2020-12-09)
|
||||
---------------------------------------------
|
||||
* DATAMONGO-2663 - Document Spring Data to MongoDB compatibility.
|
||||
* DATAMONGO-2661 - Handle nullable types for KPropertyPath.
|
||||
* DATAMONGO-2647 - Release 3.0.6 (Neumann SR6).
|
||||
* DATAMONGO-2644 - Invalid reference '_id'! Error In spring data mongodb.
|
||||
|
||||
|
||||
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.
|
||||
@@ -3156,6 +3223,15 @@ Repository
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
@@ -1,4 +1,4 @@
|
||||
Spring Data MongoDB 3.0.4 (Neumann SR4)
|
||||
Spring Data MongoDB 3.0.6 (Neumann SR6)
|
||||
Copyright (c) [2010-2019] Pivotal Software, Inc.
|
||||
|
||||
This product is licensed to you under the Apache License, Version 2.0 (the "License").
|
||||
@@ -19,3 +19,5 @@ conditions of the subcomponent's license, as noted in the LICENSE file.
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
Reference in New Issue
Block a user