Compare commits

...

12 Commits

Author SHA1 Message Date
Mark Paluch
bcd61f0dae DATAMONGO-2084 - Release version 2.0.11 (Kay SR11). 2018-10-15 12:00:38 +02:00
Mark Paluch
478594c3ca DATAMONGO-2084 - Prepare 2.0.11 (Kay SR11). 2018-10-15 11:59:39 +02:00
Mark Paluch
bb101d5e18 DATAMONGO-2084 - Updated changelog. 2018-10-15 11:59:31 +02:00
Mark Paluch
a5bc7a2a08 DATAMONGO-2094 - Updated changelog. 2018-10-15 11:37:27 +02:00
Christoph Strobl
6720967e19 DATAMONGO-2101 - Fix DBObject to GeoJson conversion.
Querydsl still wraps MongoDB data in DBObject which causes trouble with the registered converters that deal with Document to entity conversion. Therefore we now try to extract the argument map from the DBObject transferring it to Document in order to have the converters kick in where applicable.

Original pull request: #614.
2018-10-08 09:40:23 +02:00
Mark Paluch
99a4661e81 DATAMONGO-2096 - Polishing.
Migrate assertions to AssertJ.

Original pull request: #613.
2018-10-05 15:02:45 +02:00
Christoph Strobl
338bc30b96 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:02:45 +02:00
Mark Paluch
7fa3f0068b DATAMONGO-2061 - Updated changelog. 2018-09-21 08:13:15 -04:00
Khaled Baklouti
abc74fdcc6 DATAMONGO-2087 - Fix typo in MongoRepository.
Original Pull Request: #610
2018-09-20 09:18:44 +02:00
Mark Paluch
3a895588c8 DATAMONGO-2086 - Fix Fluent API Kotlin extension generics to allow projections.
We now fixed Kotlin extension generics to properly use projections by ignoring the source type of the Fluent API object. Previously, the source and target type were linked which prevented the use of a different result type.
2018-09-17 13:59:45 +02:00
Mark Paluch
f79d98ce23 DATAMONGO-2034 - After release cleanups. 2018-09-10 13:52:27 +02:00
Mark Paluch
2bcc0d8185 DATAMONGO-2034 - Prepare next development iteration. 2018-09-10 13:52:26 +02:00
17 changed files with 145 additions and 102 deletions

View File

@@ -5,7 +5,7 @@
<groupId>org.springframework.data</groupId>
<artifactId>spring-data-mongodb-parent</artifactId>
<version>2.0.10.RELEASE</version>
<version>2.0.11.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.0.10.RELEASE</version>
<version>2.0.11.RELEASE</version>
</parent>
<modules>
@@ -27,7 +27,7 @@
<properties>
<project.type>multi</project.type>
<dist.id>spring-data-mongodb</dist.id>
<springdata.commons>2.0.10.RELEASE</springdata.commons>
<springdata.commons>2.0.11.RELEASE</springdata.commons>
<mongo>3.5.0</mongo>
<mongo.reactivestreams>1.6.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.0.10.RELEASE</version>
<version>2.0.11.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>2.0.10.RELEASE</version>
<version>2.0.11.RELEASE</version>
<relativePath>../pom.xml</relativePath>
</parent>
@@ -50,7 +50,7 @@
<dependency>
<groupId>org.springframework.data</groupId>
<artifactId>spring-data-mongodb</artifactId>
<version>2.0.10.RELEASE</version>
<version>2.0.11.RELEASE</version>
</dependency>
<!-- reactive -->

View File

@@ -13,7 +13,7 @@
<parent>
<groupId>org.springframework.data</groupId>
<artifactId>spring-data-mongodb-parent</artifactId>
<version>2.0.10.RELEASE</version>
<version>2.0.11.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.0.10.RELEASE</version>
<version>2.0.11.RELEASE</version>
<relativePath>../pom.xml</relativePath>
</parent>

View File

@@ -103,8 +103,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) {
@@ -112,7 +112,7 @@ public class GraphLookupOperation implements InheritsFieldsAggregationOperation
}
if (depthField != null) {
graphLookup.put("depthField", depthField.getName());
graphLookup.put("depthField", depthField.getTarget());
}
if (restrictSearchWithMatch != null) {

View File

@@ -50,6 +50,7 @@ import org.springframework.data.mongodb.core.mapping.MongoPersistentProperty;
import org.springframework.data.mongodb.core.mapping.event.AfterConvertEvent;
import org.springframework.data.mongodb.core.mapping.event.AfterLoadEvent;
import org.springframework.data.mongodb.core.mapping.event.MongoMappingEvent;
import org.springframework.data.mongodb.util.BsonUtils;
import org.springframework.data.util.ClassTypeInformation;
import org.springframework.data.util.TypeInformation;
import org.springframework.lang.Nullable;
@@ -207,6 +208,8 @@ public class MappingMongoConverter extends AbstractMongoConverter implements App
if (conversions.hasCustomReadTarget(bson.getClass(), rawType)) {
return conversionService.convert(bson, rawType);
} else if (bson instanceof DBObject && conversions.hasCustomReadTarget(Document.class, rawType)) {
return conversionService.convert(new Document(BsonUtils.asMap(bson)), rawType);
}
if (DBObject.class.isAssignableFrom(rawType)) {

View File

@@ -30,6 +30,7 @@ import org.springframework.data.repository.query.QueryByExampleExecutor;
* @author Christoph Strobl
* @author Thomas Darimont
* @author Mark Paluch
* @author Khaled Baklouti
*/
@NoRepositoryBean
public interface MongoRepository<T, ID> extends PagingAndSortingRepository<T, ID>, QueryByExampleExecutor<T> {
@@ -39,7 +40,7 @@ public interface MongoRepository<T, ID> extends PagingAndSortingRepository<T, ID
* @see org.springframework.data.repository.CrudRepository#saveAll(java.lang.Iterable)
*/
@Override
<S extends T> List<S> saveAll(Iterable<S> entites);
<S extends T> List<S> saveAll(Iterable<S> entities);
/*
* (non-Javadoc)

View File

@@ -1,5 +1,5 @@
/*
* Copyright 2017 the original author or authors.
* Copyright 2017-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.
@@ -25,7 +25,7 @@ import kotlin.reflect.KClass
* @since 2.0
*/
fun <T : Any> ExecutableFindOperation.query(entityClass: KClass<T>): ExecutableFindOperation.ExecutableFind<T> =
query(entityClass.java)
query(entityClass.java)
/**
* Extension for [ExecutableFindOperation.query] leveraging reified type parameters.
@@ -35,8 +35,7 @@ fun <T : Any> ExecutableFindOperation.query(entityClass: KClass<T>): ExecutableF
* @since 2.0
*/
inline fun <reified T : Any> ExecutableFindOperation.query(): ExecutableFindOperation.ExecutableFind<T> =
query(T::class.java)
query(T::class.java)
/**
* Extension for [ExecutableFindOperation.FindWithProjection. as] providing a [KClass] based variant.
@@ -45,8 +44,8 @@ inline fun <reified T : Any> ExecutableFindOperation.query(): ExecutableFindOper
* @author Mark Paluch
* @since 2.0
*/
fun <T : Any> ExecutableFindOperation.FindWithProjection<T>.asType(resultType: KClass<T>): ExecutableFindOperation.FindWithQuery<T> =
`as`(resultType.java)
fun <T : Any> ExecutableFindOperation.FindWithProjection<*>.asType(resultType: KClass<T>): ExecutableFindOperation.FindWithQuery<T> =
`as`(resultType.java)
/**
* Extension for [ExecutableFindOperation.FindWithProjection. as] leveraging reified type parameters.
@@ -55,7 +54,5 @@ fun <T : Any> ExecutableFindOperation.FindWithProjection<T>.asType(resultType: K
* @author Mark Paluch
* @since 2.0
*/
inline fun <reified T : Any> ExecutableFindOperation.FindWithProjection<T>.asType(): ExecutableFindOperation.FindWithQuery<T> =
`as`(T::class.java)
inline fun <reified T : Any> ExecutableFindOperation.FindWithProjection<*>.asType(): ExecutableFindOperation.FindWithQuery<T> =
`as`(T::class.java)

View File

@@ -1,5 +1,5 @@
/*
* Copyright 2017 the original author or authors.
* Copyright 2017-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.
@@ -41,7 +41,7 @@ inline fun <reified T : Any> ReactiveFindOperation.query(): ReactiveFindOperatio
* @author Mark Paluch
* @since 2.0
*/
fun <T : Any> ReactiveFindOperation.FindWithProjection<T>.asType(resultType: KClass<T>): ReactiveFindOperation.FindWithQuery<T> =
fun <T : Any> ReactiveFindOperation.FindWithProjection<*>.asType(resultType: KClass<T>): ReactiveFindOperation.FindWithQuery<T> =
`as`(resultType.java)
/**
@@ -50,7 +50,7 @@ fun <T : Any> ReactiveFindOperation.FindWithProjection<T>.asType(resultType: KCl
* @author Mark Paluch
* @since 2.0
*/
inline fun <reified T : Any> ReactiveFindOperation.FindWithProjection<T>.asType(): ReactiveFindOperation.FindWithQuery<T> =
inline fun <reified T : Any> ReactiveFindOperation.FindWithProjection<*>.asType(): ReactiveFindOperation.FindWithQuery<T> =
`as`(T::class.java)

View File

@@ -15,19 +15,15 @@
*/
package org.springframework.data.mongodb.core.aggregation;
import static org.hamcrest.core.Is.*;
import static org.junit.Assert.*;
import static org.springframework.data.mongodb.test.util.IsBsonObject.*;
import static org.springframework.data.mongodb.test.util.Assertions.*;
import java.util.Arrays;
import org.bson.Document;
import org.junit.Test;
import org.springframework.data.mongodb.core.Person;
import org.springframework.data.mongodb.core.query.Criteria;
import com.mongodb.BasicDBObject;
import com.mongodb.DBObject;
import com.mongodb.util.JSON;
/**
* Unit tests for {@link GraphLookupOperation}.
*
@@ -54,8 +50,7 @@ public class GraphLookupOperationUnitTests {
.as("reportingHierarchy");
Document document = graphLookupOperation.toDocument(Aggregation.DEFAULT_CONTEXT);
assertThat(document,
isBsonObject().containing("$graphLookup.depthField", "depth").containing("$graphLookup.maxDepth", 42L));
assertThat(document).containsEntry("$graphLookup.depthField", "depth").containsEntry("$graphLookup.maxDepth", 42L);
}
@Test // DATAMONGO-1551
@@ -70,8 +65,7 @@ public class GraphLookupOperationUnitTests {
.as("reportingHierarchy");
Document document = graphLookupOperation.toDocument(Aggregation.DEFAULT_CONTEXT);
assertThat(document,
isBsonObject().containing("$graphLookup.restrictSearchWithMatch", new Document("key", "value")));
assertThat(document).containsEntry("$graphLookup.restrictSearchWithMatch", new Document("key", "value"));
}
@Test // DATAMONGO-1551
@@ -86,9 +80,9 @@ public class GraphLookupOperationUnitTests {
Document document = graphLookupOperation.toDocument(Aggregation.DEFAULT_CONTEXT);
assertThat(document,
is(Document.parse("{ $graphLookup : { from: \"employees\", startWith: [\"$reportsTo\", \"$boss\"], "
+ "connectFromField: \"reportsTo\", connectToField: \"name\", as: \"reportingHierarchy\" } }")));
assertThat(document)
.isEqualTo(Document.parse("{ $graphLookup : { from: \"employees\", startWith: [\"$reportsTo\", \"$boss\"], "
+ "connectFromField: \"reportsTo\", connectToField: \"name\", as: \"reportingHierarchy\" } }"));
}
@Test // DATAMONGO-1551
@@ -103,9 +97,8 @@ public class GraphLookupOperationUnitTests {
Document document = graphLookupOperation.toDocument(Aggregation.DEFAULT_CONTEXT);
assertThat(document,
is(Document.parse("{ $graphLookup : { from: \"employees\", startWith: [\"$reportsTo\", { $literal: \"$boss\"}], "
+ "connectFromField: \"reportsTo\", connectToField: \"name\", as: \"reportingHierarchy\" } }")));
assertThat(document).containsEntry("$graphLookup.startWith",
Arrays.asList("$reportsTo", new Document("$literal", "$boss")));
}
@Test(expected = IllegalArgumentException.class) // DATAMONGO-1551
@@ -131,7 +124,39 @@ public class GraphLookupOperationUnitTests {
Document document = graphLookupOperation.toDocument(Aggregation.DEFAULT_CONTEXT);
assertThat(document, is(Document.parse("{ $graphLookup : { from: \"employees\", startWith: { $literal: \"hello\"}, "
+ "connectFromField: \"reportsTo\", connectToField: \"name\", as: \"reportingHierarchy\" } }")));
assertThat(document).containsEntry("$graphLookup.startWith", new Document("$literal", "hello"));
}
@Test // DATAMONGO-2096
public void connectFromShouldUseTargetFieldInsteadOfAlias() {
AggregationOperation graphLookupOperation = Aggregation.graphLookup("user").startWith("contacts.userId")
.connectFrom("contacts.userId").connectTo("_id").depthField("numConnections").as("connections");
Document document = graphLookupOperation.toDocument(Aggregation.DEFAULT_CONTEXT);
assertThat(document).containsEntry("$graphLookup.startWith", "$contacts.userId");
}
@Test // DATAMONGO-2096
public void connectToShouldUseTargetFieldInsteadOfAlias() {
AggregationOperation graphLookupOperation = Aggregation.graphLookup("user").startWith("contacts.userId")
.connectFrom("userId").connectTo("connectto.field").depthField("numConnections").as("connections");
Document document = graphLookupOperation.toDocument(Aggregation.DEFAULT_CONTEXT);
assertThat(document).containsEntry("$graphLookup.connectToField", "connectto.field");
}
@Test // DATAMONGO-2096
public void depthFieldShouldUseTargetFieldInsteadOfAlias() {
AggregationOperation graphLookupOperation = Aggregation.graphLookup("user").startWith("contacts.userId")
.connectFrom("contacts.userId").connectTo("_id").depthField("foo.bar").as("connections");
Document document = graphLookupOperation.toDocument(Aggregation.DEFAULT_CONTEXT);
assertThat(document).containsEntry("$graphLookup.depthField", "foo.bar");
}
}

View File

@@ -15,18 +15,28 @@
*/
package org.springframework.data.mongodb.repository;
import lombok.Getter;
import lombok.Setter;
import org.springframework.data.mongodb.core.geo.GeoJson;
import com.querydsl.core.annotations.QueryEmbeddable;
/**
* @author Oliver Gierke
* @author Christoph Strobl
*/
@QueryEmbeddable
@Getter
@Setter
public class Address {
private String street;
private String zipCode;
private String city;
private GeoJson location;
protected Address() {
}
@@ -41,46 +51,4 @@ public class Address {
this.zipCode = zipcode;
this.city = city;
}
/**
* @return the street
*/
public String getStreet() {
return street;
}
/**
* @param street the street to set
*/
public void setStreet(String street) {
this.street = street;
}
/**
* @return the zipCode
*/
public String getZipCode() {
return zipCode;
}
/**
* @param zipCode the zipCode to set
*/
public void setZipCode(String zipCode) {
this.zipCode = zipCode;
}
/**
* @return the city
*/
public String getCity() {
return city;
}
/**
* @param city the city to set
*/
public void setCity(String city) {
this.city = city;
}
}

View File

@@ -28,6 +28,8 @@ import org.springframework.dao.IncorrectResultSizeDataAccessException;
import org.springframework.data.domain.Sort;
import org.springframework.data.domain.Sort.Direction;
import org.springframework.data.mongodb.core.MongoOperations;
import org.springframework.data.mongodb.core.geo.GeoJsonPoint;
import org.springframework.data.mongodb.repository.Address;
import org.springframework.data.mongodb.repository.Person;
import org.springframework.data.mongodb.repository.QPerson;
import org.springframework.data.mongodb.repository.query.MongoEntityInformation;
@@ -99,4 +101,21 @@ public class QuerydslMongoPredicateExecutorIntegrationTests {
public void findOneWithPredicateThrowsExceptionForNonUniqueResults() {
repository.findOne(person.firstname.contains("e"));
}
@Test // DATAMONGO-2101
public void readEntityWithGeoJsonValue() {
Address adr1 = new Address("Hauptplatz", "4020", "Linz");
adr1.setLocation(new GeoJsonPoint(48.3063548, 14.2851337));
Person person1 = new Person("Max", "The Mighty");
person1.setAddress(adr1);
operations.save(person1);
List<Person> result = new SpringDataMongodbQuery<>(operations, Person.class).where(person.firstname.eq("Max"))
.fetch();
assertThat(result).containsExactly(person1);
}
}

View File

@@ -1,5 +1,5 @@
/*
* Copyright 2017 the original author or authors.
* Copyright 2017-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.
@@ -50,18 +50,17 @@ class ExecutableFindOperationExtensionsTests {
verify(operation).query(First::class.java)
}
@Test // DATAMONGO-1689
@Test // DATAMONGO-1689, DATAMONGO-2086
fun `ExecutableFindOperation#FindOperationWithProjection#asType(KClass) extension should call its Java counterpart`() {
operationWithProjection.asType(First::class)
verify(operationWithProjection).`as`(First::class.java)
operationWithProjection.asType(User::class)
verify(operationWithProjection).`as`(User::class.java)
}
@Test // DATAMONGO-1689
@Test // DATAMONGO-1689, DATAMONGO-2086
fun `ExecutableFindOperation#FindOperationWithProjection#asType() with reified type parameter extension should call its Java counterpart`() {
operationWithProjection.asType()
verify(operationWithProjection).`as`(First::class.java)
operationWithProjection.asType<User>()
verify(operationWithProjection).`as`(User::class.java)
}
}

View File

@@ -1,5 +1,5 @@
/*
* Copyright 2017 the original author or authors.
* Copyright 2017-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.
@@ -49,17 +49,17 @@ class ReactiveFindOperationExtensionsTests {
verify(operation).query(First::class.java)
}
@Test // DATAMONGO-1719
@Test // DATAMONGO-1719, DATAMONGO-2086
fun `ReactiveFind#FindOperatorWithProjection#asType(KClass) extension should call its Java counterpart`() {
operationWithProjection.asType(First::class)
verify(operationWithProjection).`as`(First::class.java)
operationWithProjection.asType(User::class)
verify(operationWithProjection).`as`(User::class.java)
}
@Test // DATAMONGO-1719
@Test // DATAMONGO-1719, DATAMONGO-2086
fun `ReactiveFind#FindOperatorWithProjection#asType() with reified type parameter extension should call its Java counterpart`() {
operationWithProjection.asType()
verify(operationWithProjection).`as`(First::class.java)
operationWithProjection.asType<User>()
verify(operationWithProjection).`as`(User::class.java)
}
}

View File

@@ -1,6 +1,37 @@
Spring Data MongoDB Changelog
=============================
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.

View File

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