Compare commits

...

19 Commits

Author SHA1 Message Date
Mark Paluch
4414771aaa DATAMONGO-2110 - Release version 1.10.17 (Ingalls SR17). 2018-11-27 10:15:45 +01:00
Mark Paluch
9acc558ae9 DATAMONGO-2110 - Prepare 1.10.17 (Ingalls SR17). 2018-11-27 10:14:58 +01:00
Mark Paluch
2d946a2c9a DATAMONGO-2110 - Updated changelog. 2018-11-27 10:14:54 +01:00
Oliver Drotbohm
715a2d3da4 DATAMONGO-2135 - Polishing. 2018-11-15 15:54:22 +01:00
Oliver Drotbohm
01c1ec2e5b DATAMONGO-2135 - Default to intermediate List for properties typed to Collection.
We now defensively create a List rather than a LinkedHashSet (which Spring's CollectionFactory.createCollection(…) defaults to) to make sure we're not accidentally dropping values that are considered equal according to their Java class definition.
2018-11-15 15:54:18 +01:00
Mark Paluch
7596f37235 DATAMONGO-2107 - Updated changelog. 2018-10-29 14:30:31 +01:00
Mona Mohamadinia
da4ccaa975 DATAMONGO-2118 - Fix typo in repositories reference documentation.
Original pull request: #611.
2018-10-26 10:08:55 +02:00
Mark Paluch
aed9b4d0da DATAMONGO-2083 - After release cleanups. 2018-10-15 13:55:50 +02:00
Mark Paluch
54a0e34049 DATAMONGO-2083 - Prepare next development iteration. 2018-10-15 13:55:49 +02:00
Mark Paluch
6cb8055601 DATAMONGO-2083 - Release version 1.10.16 (Ingalls SR16). 2018-10-15 12:56:30 +02:00
Mark Paluch
34829fca84 DATAMONGO-2083 - Prepare 1.10.16 (Ingalls SR16). 2018-10-15 12:55:35 +02:00
Mark Paluch
94b2495145 DATAMONGO-2083 - Updated changelog. 2018-10-15 12:55:29 +02:00
Mark Paluch
f2301eaf5b DATAMONGO-2084 - Updated changelog. 2018-10-15 12:46:26 +02:00
Mark Paluch
e3e201edb9 DATAMONGO-2094 - Updated changelog. 2018-10-15 11:37:25 +02:00
Christoph Strobl
c738148b40 DATAMONGO-2096 - Fix target field name for GraphLookup aggregation operation.
We now make sure to use the target field name instead of the alias when processing GraphLookupOperation.

Original pull request: #613.
2018-10-05 15:17:42 +02:00
Mark Paluch
ec5268a862 DATAMONGO-2061 - Updated changelog. 2018-09-21 08:13:12 -04:00
Mark Paluch
9bc073501f DATAMONGO-2034 - Updated changelog. 2018-09-10 14:15:51 +02:00
Mark Paluch
3d00ef1076 DATAMONGO-2035 - After release cleanups. 2018-09-10 10:01:44 +02:00
Mark Paluch
a07ca615be DATAMONGO-2035 - Prepare next development iteration. 2018-09-10 10:01:43 +02:00
13 changed files with 161 additions and 23 deletions

View File

@@ -5,7 +5,7 @@
<groupId>org.springframework.data</groupId>
<artifactId>spring-data-mongodb-parent</artifactId>
<version>1.10.15.RELEASE</version>
<version>1.10.17.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>1.9.15.RELEASE</version>
<version>1.9.17.RELEASE</version>
</parent>
<modules>
@@ -28,7 +28,7 @@
<properties>
<project.type>multi</project.type>
<dist.id>spring-data-mongodb</dist.id>
<springdata.commons>1.13.15.RELEASE</springdata.commons>
<springdata.commons>1.13.17.RELEASE</springdata.commons>
<mongo>2.14.3</mongo>
<mongo.osgi>2.13.0</mongo.osgi>
<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>1.10.15.RELEASE</version>
<version>1.10.17.RELEASE</version>
<relativePath>../pom.xml</relativePath>
</parent>

View File

@@ -6,7 +6,7 @@
<parent>
<groupId>org.springframework.data</groupId>
<artifactId>spring-data-mongodb-parent</artifactId>
<version>1.10.15.RELEASE</version>
<version>1.10.17.RELEASE</version>
<relativePath>../pom.xml</relativePath>
</parent>
@@ -49,7 +49,7 @@
<dependency>
<groupId>org.springframework.data</groupId>
<artifactId>spring-data-mongodb</artifactId>
<version>1.10.15.RELEASE</version>
<version>1.10.17.RELEASE</version>
</dependency>
<dependency>

View File

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

View File

@@ -5,7 +5,7 @@
<parent>
<groupId>org.springframework.data</groupId>
<artifactId>spring-data-mongodb-parent</artifactId>
<version>1.10.15.RELEASE</version>
<version>1.10.17.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>1.10.15.RELEASE</version>
<version>1.10.17.RELEASE</version>
<relativePath>../pom.xml</relativePath>
</parent>

View File

@@ -104,8 +104,8 @@ public class GraphLookupOperation implements InheritsFieldsAggregationOperation
graphLookup.put("startWith", mappedStartWith.size() == 1 ? mappedStartWith.iterator().next() : mappedStartWith);
graphLookup.put("connectFromField", connectFrom.getName());
graphLookup.put("connectToField", connectTo.getName());
graphLookup.put("connectFromField", connectFrom.getTarget());
graphLookup.put("connectToField", connectTo.getTarget());
graphLookup.put("as", as.getName());
if (maxDepth != null) {
@@ -113,7 +113,7 @@ public class GraphLookupOperation implements InheritsFieldsAggregationOperation
}
if (depthField != null) {
graphLookup.put("depthField", depthField.getName());
graphLookup.put("depthField", depthField.getTarget());
}
if (restrictSearchWithMatch != null) {

View File

@@ -28,7 +28,6 @@ import java.util.Set;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
import org.springframework.beans.BeansException;
import org.springframework.context.ApplicationContext;
import org.springframework.context.ApplicationContextAware;
@@ -531,7 +530,7 @@ public class MappingMongoConverter extends AbstractMongoConverter implements App
: new BasicDBObject();
addCustomTypeKeyIfNecessary(ClassTypeInformation.from(prop.getRawType()), obj, propDbObj);
MongoPersistentEntity<?> entity = isSubtype(prop.getType(), obj.getClass())
MongoPersistentEntity<?> entity = isSubTypeOf(obj.getClass(), prop.getType())
? mappingContext.getPersistentEntity(obj.getClass())
: mappingContext.getPersistentEntity(type);
@@ -539,10 +538,6 @@ public class MappingMongoConverter extends AbstractMongoConverter implements App
accessor.put(prop, propDbObj);
}
private boolean isSubtype(Class<?> left, Class<?> right) {
return left.isAssignableFrom(right) && !left.equals(right);
}
/**
* Returns given object as {@link Collection}. Will return the {@link Collection} as is if the source is a
* {@link Collection} already, will convert an array into a {@link Collection} or simply create a single element
@@ -910,7 +905,7 @@ public class MappingMongoConverter extends AbstractMongoConverter implements App
TypeInformation<?> componentType = targetType.getComponentType();
Class<?> rawComponentType = componentType == null ? null : componentType.getType();
collectionType = Collection.class.isAssignableFrom(collectionType) ? collectionType : List.class;
collectionType = isSubTypeOf(collectionType, Collection.class) ? collectionType : List.class;
Collection<Object> items = targetType.getType().isArray() ? new ArrayList<Object>()
: CollectionFactory.createCollection(collectionType, rawComponentType, sourceValue.size());
@@ -920,7 +915,7 @@ public class MappingMongoConverter extends AbstractMongoConverter implements App
if (!DBRef.class.equals(rawComponentType) && isCollectionOfDbRefWhereBulkFetchIsPossible(sourceValue)) {
List<Object> objects = bulkReadAndConvertDBRefs((List<DBRef>)(List) sourceValue, componentType, path,
List<Object> objects = bulkReadAndConvertDBRefs((List<DBRef>) (List) sourceValue, componentType, path,
rawComponentType);
return getPotentiallyConvertedSimpleRead(objects, targetType.getType());
}
@@ -1360,6 +1355,17 @@ public class MappingMongoConverter extends AbstractMongoConverter implements App
return true;
}
/**
* Returns whether the given type is a sub type of the given reference, i.e. assignable but not the exact same type.
*
* @param type must not be {@literal null}.
* @param reference must not be {@literal null}.
* @return
*/
private static boolean isSubTypeOf(Class<?> type, Class<?> reference) {
return !type.equals(reference) && reference.isAssignableFrom(type);
}
/**
* Marker class used to indicate we have a non root document object here that might be used within an update - so we
* need to preserve type hints for potential nested elements but need to remove it on top level.

View File

@@ -133,4 +133,40 @@ public class GraphLookupOperationUnitTests {
assertThat(dbObject, is(JSON.parse("{ $graphLookup : { from: \"employees\", startWith: { $literal: \"hello\"}, "
+ "connectFromField: \"reportsTo\", connectToField: \"name\", as: \"reportingHierarchy\" } }")));
}
@Test // DATAMONGO-2096
public void connectFromShouldUseTargetFieldInsteadOfAlias() {
AggregationOperation graphLookupOperation = Aggregation.graphLookup("user").startWith("contacts.userId")
.connectFrom("contacts.userId").connectTo("_id").depthField("numConnections").as("connections");
DBObject document = graphLookupOperation.toDBObject(Aggregation.DEFAULT_CONTEXT);
assertThat(document, is(JSON.parse(
"{ \"$graphLookup\" : { \"from\" : \"user\", \"startWith\" : \"$contacts.userId\", \"connectFromField\" : \"contacts.userId\", \"connectToField\" : \"_id\", \"as\" : \"connections\", \"depthField\" : \"numConnections\" } }")));
}
@Test // DATAMONGO-2096
public void connectToShouldUseTargetFieldInsteadOfAlias() {
AggregationOperation graphLookupOperation = Aggregation.graphLookup("user").startWith("contacts.userId")
.connectFrom("userId").connectTo("connectto.field").depthField("numConnections").as("connections");
DBObject document = graphLookupOperation.toDBObject(Aggregation.DEFAULT_CONTEXT);
assertThat(document, is(JSON.parse(
"{ \"$graphLookup\" : { \"from\" : \"user\", \"startWith\" : \"$contacts.userId\", \"connectFromField\" : \"userId\", \"connectToField\" : \"connectto.field\", \"as\" : \"connections\", \"depthField\" : \"numConnections\" } }")));
}
@Test // DATAMONGO-2096
public void depthFieldShouldUseTargetFieldInsteadOfAlias() {
AggregationOperation graphLookupOperation = Aggregation.graphLookup("user").startWith("contacts.userId")
.connectFrom("contacts.userId").connectTo("_id").depthField("foo.bar").as("connections");
DBObject document = graphLookupOperation.toDBObject(Aggregation.DEFAULT_CONTEXT);
assertThat(document, is(JSON.parse(
"{ \"$graphLookup\" : { \"from\" : \"user\", \"startWith\" : \"$contacts.userId\", \"connectFromField\" : \"contacts.userId\", \"connectToField\" : \"_id\", \"as\" : \"connections\", \"depthField\" : \"foo.bar\" } }")));
}
}

View File

@@ -1,5 +1,5 @@
/*
* Copyright 2011-2017 the original author or authors.
* Copyright 2011-2018 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.
@@ -21,6 +21,7 @@ import static org.junit.Assert.*;
import static org.mockito.Mockito.*;
import static org.springframework.data.mongodb.core.DBObjectTestUtils.*;
import lombok.EqualsAndHashCode;
import lombok.RequiredArgsConstructor;
import java.math.BigDecimal;
@@ -1862,6 +1863,23 @@ public class MappingMongoConverterUnitTests {
assertThat(target.get("_class"), is(nullValue()));
}
@Test // DATAMONGO-2135
public void addsEqualObjectsToCollection() {
DBObject itemDocument = new BasicDBObject("itemKey", "123");
BasicDBList items = new BasicDBList();
items.add(itemDocument);
items.add(itemDocument);
items.add(itemDocument);
DBObject orderDocument = new BasicDBObject("items", items);
Order order = converter.read(Order.class, orderDocument);
assertThat(order.items, hasSize(3));
}
static class GenericType<T> {
T content;
}
@@ -2232,4 +2250,15 @@ public class MappingMongoConverterUnitTests {
static class DocWithInterfacedEnum {
SomeInterface property;
}
// DATAMONGO-2135
@EqualsAndHashCode // equality check by fields
static class SomeItem {
String itemKey;
}
static class Order {
Collection<SomeItem> items = new ArrayList<SomeItem>();
}
}

View File

@@ -34,7 +34,7 @@ Note that the domain type shown in the preceding example has a property named `i
====
[source]
----
public interface PersonRepository extends PagingAndSortingRepository<Person, Long> {
public interface PersonRepository extends PagingAndSortingRepository<Person, String> {
// additional custom query methods go here
}

View File

@@ -1,6 +1,73 @@
Spring Data MongoDB Changelog
=============================
Changes in version 1.10.17.RELEASE (2018-11-27)
-----------------------------------------------
* DATAMONGO-2135 - Use List instead of Collection when reading data with MappingMongoConverter.
* DATAMONGO-2118 - Fix typo in repositories reference documentation.
* DATAMONGO-2110 - Release 1.10.17 (Ingalls SR17).
Changes in version 2.1.2.RELEASE (2018-10-29)
---------------------------------------------
* DATAMONGO-2118 - Fix typo in repositories reference documentation.
* DATAMONGO-2113 - ChangeStreamTasks incorrectly converts resumeAt Instants into BsonTimestamp.
* DATAMONGO-2107 - Release 2.1.2 (Lovelace SR2).
* DATAMONGO-2098 - Typo in MappingMongoConverterParser.
Changes in version 1.10.16.RELEASE (2018-10-15)
-----------------------------------------------
* DATAMONGO-2096 - Aggregation.graphLookup.**.connectFrom(String) does not handle nested field.
* DATAMONGO-2083 - Release 1.10.16 (Ingalls SR16).
Changes in version 2.0.11.RELEASE (2018-10-15)
----------------------------------------------
* DATAMONGO-2101 - NoSuchMethodException: org.springframework.data.mongodb.core.geo.GeoJsonPoint.<init>().
* DATAMONGO-2096 - Aggregation.graphLookup.**.connectFrom(String) does not handle nested field.
* DATAMONGO-2087 - Typo in MongoRepository.
* DATAMONGO-2086 - Kotlin Fluent API extensions do not allow projections with find queries.
* DATAMONGO-2084 - Release 2.0.11 (Kay SR11).
Changes in version 2.1.1.RELEASE (2018-10-15)
---------------------------------------------
* DATAMONGO-2096 - Aggregation.graphLookup.**.connectFrom(String) does not handle nested field.
* DATAMONGO-2094 - Release 2.1.1 (Lovelace SR1).
Changes in version 2.1.0.RELEASE (2018-09-21)
---------------------------------------------
* DATAMONGO-2091 - Upgrade to MongoDB Java Driver 3.8.2 and Reactive Streams Driver 1.9.2.
* DATAMONGO-2090 - Include documentation about Object Mapping Fundamentals.
* DATAMONGO-2087 - Typo in MongoRepository.
* DATAMONGO-2086 - Kotlin Fluent API extensions do not allow projections with find queries.
* DATAMONGO-2080 - DTO projections with reactive @Tailable query methods fail with IllegalArgumentException: Property must not be null.
* DATAMONGO-2078 - Update reference documentation on tailable cursors with the sync MongoDB Java driver.
* DATAMONGO-2076 - Fix property substitution in getting started section of reference docs.
* DATAMONGO-2075 - Open up MongoTransaction manager to allow transaction commit retry..
* DATAMONGO-2069 - Required dependency 'mysema-commons-lang'.
* DATAMONGO-2065 - Make sure that MongoTemplate.doSave(…) calls local populateIdIfNecessary(…) to allow customization.
* DATAMONGO-2064 - Upgrade to MongoDB Java Driver 3.8.1.
* DATAMONGO-2061 - Release 2.1 GA (Lovelace).
Changes in version 2.0.10.RELEASE (2018-09-10)
----------------------------------------------
* DATAMONGO-2076 - Fix property substitution in getting started section of reference docs.
* DATAMONGO-2055 - Allow position modifier to be negative using push at position on Update.
* DATAMONGO-2051 - Add support for SCRAM-SHA-256 authentication mechanism to MongoCredentialPropertyEditor.
* DATAMONGO-2050 - Add support for index selection via key attribute for $geoNear aggregation.
* DATAMONGO-2049 - Add support for MongoDB 4.0 string aggregation operators.
* DATAMONGO-2048 - Add support for MongoDB 4.0 type conversion aggregation operators.
* DATAMONGO-2047 - Update $dateToString and $dateFromString aggregation operators to match MongoDB 4.0 changes.
* DATAMONGO-2046 - Investigate performance regressions between 2.0 GA and 2.1 RC2.
* DATAMONGO-2043 - MappingMongoConverter.write(…) does not consider Document a native type and adds _class attribute.
* DATAMONGO-2034 - Release 2.0.10 (Kay SR10).
* DATAMONGO-2027 - outputCollection and outputType of MapReduceOptions not work.
Changes in version 1.10.15.RELEASE (2018-09-10)
-----------------------------------------------
* DATAMONGO-2076 - Fix property substitution in getting started section of reference docs.

View File

@@ -1,4 +1,4 @@
Spring Data MongoDB 1.10.15
Spring Data MongoDB 1.10.17
Copyright (c) [2010-2015] Pivotal Software, Inc.
This product is licensed to you under the Apache License, Version 2.0 (the "License").