Compare commits

...

37 Commits

Author SHA1 Message Date
Mark Paluch
c7e4673e29 DATAMONGO-2532 - Release version 2.1.18 (Lovelace SR18). 2020-06-10 10:53:41 +02:00
Mark Paluch
9d694dbdd5 DATAMONGO-2532 - Prepare 2.1.18 (Lovelace SR18). 2020-06-10 10:53:13 +02:00
Mark Paluch
74179a9af9 DATAMONGO-2532 - Updated changelog. 2020-06-10 10:53:01 +02:00
Christoph Strobl
c1c5e3bdbb DATAMONGO-2547 - Use target class ClassLoader instead of default CL when creating proxy instances.
Original pull request: #865.
2020-05-26 08:55:47 +02:00
Greg Turnquist
24978577cc DATAMONGO-2535 - Remove Travis CI. 2020-05-04 15:09:31 -05:00
Mark Paluch
c43ae822be DATAMONGO-2503 - Updated changelog. 2020-04-28 15:12:26 +02:00
Mark Paluch
881a69864f DATAMONGO-2500 - Updated changelog. 2020-04-28 14:46:52 +02:00
Mark Paluch
dc054a793f DATAMONGO-2484 - After release cleanups. 2020-04-28 11:55:28 +02:00
Mark Paluch
f048fb6800 DATAMONGO-2484 - Prepare next development iteration. 2020-04-28 11:55:27 +02:00
Mark Paluch
20fdb0e63c DATAMONGO-2484 - Release version 2.1.17 (Lovelace SR17). 2020-04-28 11:32:50 +02:00
Mark Paluch
7e3ff86d36 DATAMONGO-2484 - Prepare 2.1.17 (Lovelace SR17). 2020-04-28 11:32:27 +02:00
Mark Paluch
54c9933535 DATAMONGO-2484 - Updated changelog. 2020-04-28 11:32:19 +02:00
Mark Paluch
1f07a3eb29 DATAMONGO-2529 - Ensure that MappingMongoConverter.read(…) is never called with null.
Previously, various methods attempted to pass a null argument as source for the converter. The API is non-null and implementations relying on these constraints were easily breakable.

We now make sure that the source is never null.
2020-04-23 15:25:51 +02:00
Mark Paluch
76f4328498 DATAMONGO-2492 - Updated changelog. 2020-03-31 15:08:50 +02:00
Mark Paluch
c572ca4e3b DATAMONGO-2485 - Updated changelog. 2020-03-25 10:59:48 +01:00
Christoph Strobl
f1d214b87d DATAMONGO-2300 - Polishing.
Move null check to event publishing logic.

Original Pull Request: #763
2020-03-23 10:12:48 +01:00
Heesu Jung
f4854a15f9 DATAMONGO-2300 - Add check rawType is null in readMap.
Original Pull Request: #763
2020-03-23 10:12:12 +01:00
Mark Paluch
b491d6ce81 DATAMONGO-2497 - Update documentation regarding @Transient properties usage in the persistence constructor. 2020-03-19 15:37:42 +01:00
Jens Schauder
0b482f8dcf DATAMONGO-2473 - Updated changelog. 2020-03-11 09:59:32 +01:00
Mark Paluch
9f1b27c305 DATAMONGO-2453 - Updated changelog. 2020-02-26 11:55:06 +01:00
Mark Paluch
b6e69606b1 DATAMONGO-2452 - After release cleanups. 2020-02-26 11:25:51 +01:00
Mark Paluch
0429ea69fa DATAMONGO-2452 - Prepare next development iteration. 2020-02-26 11:25:50 +01:00
Mark Paluch
383b7031dd DATAMONGO-2452 - Release version 2.1.16 (Lovelace SR16). 2020-02-26 11:11:48 +01:00
Mark Paluch
e8f0ed8d59 DATAMONGO-2452 - Prepare 2.1.16 (Lovelace SR16). 2020-02-26 11:11:28 +01:00
Mark Paluch
f90d30472b DATAMONGO-2452 - Updated changelog. 2020-02-26 11:11:23 +01:00
Mark Paluch
cec1c8305a DATAMONGO-2456 - Updated changelog. 2020-02-12 15:05:03 +01:00
Mark Paluch
cd714b1ba8 DATAMONGO-2079 - MappingMongoConverter no longer implements ValueResolver.
MappingMongoConverter no longer implements a package-private interface so that converter instances can be proxied.

Original Pull Request: #832
2020-02-04 14:52:56 +01:00
Mark Paluch
0a83eec8b2 DATAMONGO-2464 - Polishing.
Apply fix also to reactive MongoDB repository documentation.

Original pull request: #816.
2020-02-03 11:34:09 +01:00
LiangYong
3a28fb18f6 DATAMONGO-2464 - Fix code examples in reference documentation.
fixed repository miss "{" issue.

Original pull request: #816.
2020-02-03 11:34:09 +01:00
Mark Paluch
6e65d2fd1d DATAMONGO-2457 - Polishing.
Slightly tweak wording.

Original pull request: #829.
2020-01-29 09:51:31 +01:00
Christoph Strobl
8d63c10e07 DATAMONGO-2459 - Add sample for passing on limit and offset using reactive repositories.
Original pull request: #829.
2020-01-29 09:47:31 +01:00
Christoph Strobl
aee5f71229 DATAMONGO-2457 - Fix id type explanation in repository documentation.
Original pull request: #829.
2020-01-29 09:47:30 +01:00
Mark Paluch
5cc044b72c DATAMONGO-2454 - Updated changelog. 2020-01-17 09:58:35 +01:00
Mark Paluch
45243468ec DATAMONGO-2383 - Updated changelog. 2020-01-16 16:12:38 +01:00
Mark Paluch
5a162bdbaf DATAMONGO-2432 - Updated changelog. 2020-01-15 12:51:15 +01:00
Mark Paluch
1d15eaf42e DATAMONGO-2431 - After release cleanups. 2020-01-15 10:35:39 +01:00
Mark Paluch
0076e294ae DATAMONGO-2431 - Prepare next development iteration. 2020-01-15 10:35:38 +01:00
19 changed files with 281 additions and 83 deletions

View File

@@ -1,35 +0,0 @@
language: java
jdk:
- oraclejdk8
before_install:
- mkdir -p downloads
- mkdir -p var/db var/log
- if [[ ! -d downloads/mongodb-linux-x86_64-ubuntu1604-${MONGO_VERSION} ]] ; then cd downloads && wget https://fastdl.mongodb.org/linux/mongodb-linux-x86_64-ubuntu1604-${MONGO_VERSION}.tgz && tar xzf mongodb-linux-x86_64-ubuntu1604-${MONGO_VERSION}.tgz && cd ..; fi
- downloads/mongodb-linux-x86_64-ubuntu1604-${MONGO_VERSION}/bin/mongod --version
- downloads/mongodb-linux-x86_64-ubuntu1604-${MONGO_VERSION}/bin/mongod --dbpath var/db --replSet rs0 --fork --logpath var/log/mongod.log
- sleep 10
- |-
downloads/mongodb-linux-x86_64-ubuntu1604-${MONGO_VERSION}/bin/mongo --eval "rs.initiate({_id: 'rs0', members:[{_id: 0, host: '127.0.0.1:27017'}]});"
sleep 15
env:
matrix:
- PROFILE=ci
global:
- MONGO_VERSION=4.0.0
addons:
apt:
packages:
- oracle-java8-installer
sudo: false
cache:
directories:
- $HOME/.m2
- downloads
script: "mvn clean dependency:list test -P${PROFILE} -Dsort"

View File

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

View File

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

View File

@@ -265,7 +265,7 @@ public abstract class MongoDbFactorySupport<C> implements MongoDbFactory {
factory.addAdvice(new SessionAwareMethodInterceptor<>(session, target, ClientSession.class, MongoDatabase.class,
this::proxyDatabase, MongoCollection.class, this::proxyCollection));
return targetType.cast(factory.getProxy());
return targetType.cast(factory.getProxy(target.getClass().getClassLoader()));
}
}

View File

@@ -3029,12 +3029,13 @@ public class MongoTemplate implements MongoOperations, ApplicationContextAware,
@Nullable
public T doWith(@Nullable Document object) {
T source = null;
if (null != object) {
maybeEmitEvent(new AfterLoadEvent<>(object, type, collectionName));
source = reader.read(type, object);
}
T source = reader.read(type, object);
if (null != source) {
maybeEmitEvent(new AfterConvertEvent<>(object, source, collectionName));
}
@@ -3074,9 +3075,7 @@ public class MongoTemplate implements MongoOperations, ApplicationContextAware,
Class<?> typeToRead = targetType.isInterface() || targetType.isAssignableFrom(entityType) ? entityType
: targetType;
if (null != object) {
maybeEmitEvent(new AfterLoadEvent<>(object, targetType, collectionName));
}
maybeEmitEvent(new AfterLoadEvent<>(object, targetType, collectionName));
Object source = reader.read(typeToRead, object);
Object result = targetType.isInterface() ? projectionFactory.createProjection(targetType, source) : source;

View File

@@ -233,7 +233,7 @@ public class SimpleReactiveMongoDatabaseFactory implements DisposableBean, React
factory.addAdvice(new SessionAwareMethodInterceptor<>(session, target, ClientSession.class, MongoDatabase.class,
this::proxyDatabase, MongoCollection.class, this::proxyCollection));
return targetType.cast(factory.getProxy());
return targetType.cast(factory.getProxy(target.getClass().getClassLoader()));
}
}
}

View File

@@ -202,7 +202,7 @@ public class DefaultDbRefResolver implements DbRefResolver {
proxyFactory.addInterface(propertyType);
proxyFactory.addAdvice(interceptor);
return handler.populateId(property, dbref, proxyFactory.getProxy());
return handler.populateId(property, dbref, proxyFactory.getProxy(LazyLoadingProxy.class.getClassLoader()));
}
/**

View File

@@ -76,8 +76,9 @@ import com.mongodb.DBRef;
* @author Christoph Strobl
* @author Jordi Llach
* @author Mark Paluch
* @author Heesu Jung
*/
public class MappingMongoConverter extends AbstractMongoConverter implements ApplicationContextAware, ValueResolver {
public class MappingMongoConverter extends AbstractMongoConverter implements ApplicationContextAware {
private static final String INCOMPATIBLE_TYPES = "Cannot convert %1$s of type %2$s into an instance of %3$s! Implement a custom Converter<%2$s, %3$s> and register it with the CustomConversions. Parent object was: %4$s";
private static final String INVALID_TYPE_TO_READ = "Expected to read Document %s into type %s but didn't find a PersistentEntity for the latter!";
@@ -115,7 +116,8 @@ public class MappingMongoConverter extends AbstractMongoConverter implements App
this.idMapper = new QueryMapper(this);
this.spELContext = new SpELContext(DocumentPropertyAccessor.INSTANCE);
this.dbRefProxyHandler = new DefaultDbRefProxyHandler(spELContext, mappingContext, MappingMongoConverter.this);
this.dbRefProxyHandler = new DefaultDbRefProxyHandler(spELContext, mappingContext,
MappingMongoConverter.this::getValueInternal);
}
/**
@@ -198,11 +200,9 @@ public class MappingMongoConverter extends AbstractMongoConverter implements App
@Nullable
@SuppressWarnings("unchecked")
private <S extends Object> S read(TypeInformation<S> type, @Nullable Bson bson, ObjectPath path) {
private <S extends Object> S read(TypeInformation<S> type, Bson bson, ObjectPath path) {
if (null == bson) {
return null;
}
Assert.notNull(bson, "Bson must not be null!");
TypeInformation<? extends S> typeToUse = typeMapper.readType(bson, type);
Class<? extends S> rawType = typeToUse.getType();
@@ -394,7 +394,7 @@ public class MappingMongoConverter extends AbstractMongoConverter implements App
SpELExpressionEvaluator evaluator) {
return new DefaultDbRefResolverCallback(documentAccessor.getDocument(), currentPath, evaluator,
MappingMongoConverter.this);
MappingMongoConverter.this::getValueInternal);
}
private void readAssociation(Association<MongoPersistentProperty> association, PersistentPropertyAccessor<?> accessor,
@@ -996,7 +996,7 @@ public class MappingMongoConverter extends AbstractMongoConverter implements App
* (non-Javadoc)
* @see org.springframework.data.mongodb.core.convert.ValueResolver#getValueInternal(org.springframework.data.mongodb.core.mapping.MongoPersistentProperty, com.mongodb.Document, org.springframework.data.mapping.model.SpELExpressionEvaluator, java.lang.Object)
*/
@Override
@Nullable
public Object getValueInternal(MongoPersistentProperty prop, Bson bson, SpELExpressionEvaluator evaluator,
ObjectPath path) {
return new MongoDbPropertyValueProvider(bson, evaluator, path).getPropertyValue(prop);
@@ -1440,7 +1440,7 @@ public class MappingMongoConverter extends AbstractMongoConverter implements App
}
DbRefResolverCallback callback = new DefaultDbRefResolverCallback(accessor.getDocument(), path, evaluator,
MappingMongoConverter.this);
MappingMongoConverter.this::getValueInternal);
DBRef dbref = rawRefValue instanceof DBRef ? (DBRef) rawRefValue : null;
return (T) dbRefResolver.resolveDbRef(property, dbref, callback, dbRefProxyHandler);
@@ -1522,7 +1522,7 @@ public class MappingMongoConverter extends AbstractMongoConverter implements App
@Nullable
private <T> T readAndConvertDBRef(@Nullable DBRef dbref, TypeInformation<?> type, ObjectPath path,
final Class<?> rawType) {
@Nullable Class<?> rawType) {
List<T> result = bulkReadAndConvertDBRefs(Collections.singletonList(dbref), type, path, rawType);
return CollectionUtils.isEmpty(result) ? null : result.iterator().next();
@@ -1545,7 +1545,7 @@ public class MappingMongoConverter extends AbstractMongoConverter implements App
@SuppressWarnings("unchecked")
private <T> List<T> bulkReadAndConvertDBRefs(List<DBRef> dbrefs, TypeInformation<?> type, ObjectPath path,
final Class<?> rawType) {
@Nullable Class<?> rawType) {
if (CollectionUtils.isEmpty(dbrefs)) {
return Collections.emptyList();
@@ -1560,16 +1560,19 @@ public class MappingMongoConverter extends AbstractMongoConverter implements App
for (Document document : referencedRawDocuments) {
T target = null;
if (document != null) {
maybeEmitEvent(new AfterLoadEvent<>(document, (Class<T>) rawType, collectionName));
}
final T target = (T) read(type, document, path);
targeList.add(target);
maybeEmitEvent(
new AfterLoadEvent<>(document, (Class<T>) (rawType != null ? rawType : Object.class), collectionName));
target = (T) read(type, document, path);
}
if (target != null) {
maybeEmitEvent(new AfterConvertEvent<>(document, target, collectionName));
}
targeList.add(target);
}
return targeList;

View File

@@ -19,12 +19,14 @@ import org.bson.Document;
import org.bson.conversions.Bson;
import org.springframework.data.mapping.model.SpELExpressionEvaluator;
import org.springframework.data.mongodb.core.mapping.MongoPersistentProperty;
import org.springframework.lang.Nullable;
/**
* Internal API to trigger the resolution of properties.
*
* @author Oliver Gierke
* @author Christoph Strobl
* @author Mark Paluch
*/
interface ValueResolver {
@@ -38,6 +40,6 @@ interface ValueResolver {
* @param parent
* @return
*/
Object getValueInternal(MongoPersistentProperty prop, Bson bson, SpELExpressionEvaluator evaluator,
ObjectPath path);
@Nullable
Object getValueInternal(MongoPersistentProperty prop, Bson bson, SpELExpressionEvaluator evaluator, ObjectPath path);
}

View File

@@ -56,6 +56,6 @@ class QueryUtils {
return combinedSort;
});
return (Query) factory.getProxy();
return (Query) factory.getProxy(query.getClass().getClassLoader());
}
}

View File

@@ -96,6 +96,7 @@ import com.mongodb.DBRef;
* @author Patrik Wasik
* @author Christoph Strobl
* @author Mark Paluch
* @author Heesu Jung
*/
@RunWith(MockitoJUnitRunner.class)
public class MappingMongoConverterUnitTests {
@@ -1938,6 +1939,23 @@ public class MappingMongoConverterUnitTests {
.isEqualTo(new BasicDBObject("property", "value"));
}
@Test // DATAMONGO-2300
public void readAndConvertDBRefNestedByMapCorrectly() {
org.bson.Document cluster = new org.bson.Document("_id", 100L);
DBRef dbRef = new DBRef("clusters", 100L);
org.bson.Document data = new org.bson.Document("_id", 3L);
data.append("cluster", dbRef);
MappingMongoConverter spyConverter = spy(converter);
Mockito.doReturn(cluster).when(spyConverter).readRef(dbRef);
Map<Object, Object> result = spyConverter.readMap(ClassTypeInformation.MAP, data, ObjectPath.ROOT);
assertThat(((LinkedHashMap) result.get("cluster")).get("_id")).isEqualTo(100L);
}
static class GenericType<T> {
T content;
}

View File

@@ -391,7 +391,7 @@ The MappingMongoConverter can use metadata to drive the mapping of objects to do
* `@GeoSpatialIndexed`: Applied at the field level to describe how to geoindex the field.
* `@TextIndexed`: Applied at the field level to mark the field to be included in the text index.
* `@Language`: Applied at the field level to set the language override property for text index.
* `@Transient`: By default all private fields are mapped to the document, this annotation excludes the field where it is applied from being stored in the database
* `@Transient`: By default, all fields are mapped to the document. This annotation excludes the field where it is applied from being stored in the database. Transient properties cannot be used within a persistence constructor as the converter cannot materialize a value for the constructor argument.
* `@PersistenceConstructor`: Marks a given constructor - even a package protected one - to use when instantiating the object from the database. Constructor arguments are mapped by name to the key values in the retrieved Document.
* `@Value`: This annotation is part of the Spring Framework . Within the mapping framework it can be applied to constructor arguments. This lets you use a Spring Expression Language statement to transform a key's value retrieved in the database before it is used to construct a domain object. In order to reference a property of a given document one has to use expressions like: `@Value("#root.myProperty")` where `root` refers to the root of the given document.
* `@Field`: Applied at the field level and described the name of the field as it will be represented in the MongoDB BSON document thus allowing the name to be different than the fieldname of the class.

View File

@@ -28,7 +28,10 @@ public class Person {
----
====
Note that the domain type shown in the preceding example has a property named `id` of type `ObjectId`. The default serialization mechanism used in `MongoTemplate` (which backs the repository support) regards properties named `id` as the document ID. Currently, we support `String`, `ObjectId`, and `BigInteger` as ID types. Now that we have a domain object, we can define an interface that uses it, as follows:
Note that the domain type shown in the preceding example has a property named `id` of type `String`. The default serialization mechanism used in `MongoTemplate` (which backs the repository support) regards properties named `id` as the document ID. Currently, we support `String`, `ObjectId`, and `BigInteger` as ID types.
Please see <<mongo-template.id-handling, ID mapping>> for more information about on how the `id` field is handled in the mapping layer.
Now that we have a domain object, we can define an interface that uses it, as follows:
.Basic repository interface to persist Person entities
====
@@ -93,7 +96,7 @@ class ApplicationConfig extends AbstractMongoConfiguration {
@Override
protected String getMappingBasePackage() {
return "com.oreilly.springdata.mongodb"
return "com.oreilly.springdata.mongodb";
}
}
----
@@ -309,7 +312,7 @@ The following example shows how to define a `near` query that finds all persons
====
[source,java]
----
public interface PersonRepository extends MongoRepository<Person, String>
public interface PersonRepository extends MongoRepository<Person, String> {
// { 'location' : { '$near' : [point.x, point.y], '$maxDistance' : distance}}
List<Person> findByLocationNear(Point location, Distance distance);
@@ -342,7 +345,7 @@ Spring Data MongoDb supports geo-near queries, as the following example shows:
[source,java]
----
public interface PersonRepository extends MongoRepository<Person, String>
public interface PersonRepository extends MongoRepository<Person, String> {
// {'geoNear' : 'location', 'near' : [x, y] }
GeoResults<Person> findByLocationNear(Point location);
@@ -369,7 +372,7 @@ By adding the `org.springframework.data.mongodb.repository.Query` annotation to
[source,java]
----
public interface PersonRepository extends MongoRepository<Person, String>
public interface PersonRepository extends MongoRepository<Person, String> {
@Query("{ 'firstname' : ?0 }")
List<Person> findByThePersonsFirstname(String firstname);
@@ -385,7 +388,7 @@ You can also use the filter property to restrict the set of properties that is m
[source,java]
----
public interface PersonRepository extends MongoRepository<Person, String>
public interface PersonRepository extends MongoRepository<Person, String> {
@Query(value="{ 'firstname' : ?0 }", fields="{ 'firstname' : 1, 'lastname' : 1}")
List<Person> findByThePersonsFirstname(String firstname);
@@ -436,7 +439,7 @@ to declare the predicate value for `lastname` (which is equivalent to the `?0` p
[source,java]
----
public interface PersonRepository extends MongoRepository<Person, String>
public interface PersonRepository extends MongoRepository<Person, String> {
@Query("{'lastname': ?#{[0]} }")
List<Person> findByQueryWithExpression(String param0);
@@ -448,7 +451,7 @@ used in conjunction with JSON reveal a side-effect, because Map-like declaration
[source,java]
----
public interface PersonRepository extends MongoRepository<Person, String>
public interface PersonRepository extends MongoRepository<Person, String> {
@Query("{'id': ?#{ [0] ? {$exists :true} : [1] }}")
List<Person> findByQueryWithExpressionAndNestedObject(boolean param0, String param1);

View File

@@ -41,7 +41,10 @@ public class Person {
----
====
Note that the entity defined in the preceding example has a property named `id` of type `ObjectId`. The default serialization mechanism used in `MongoTemplate` (which backs the repository support) regards properties named `id` as the document ID. Currently, we support `String`, `ObjectId`, and `BigInteger` as id-types. The following example shows how to create an interface that defines queries against the `Person` object from the preceding example:
Note that the entity defined in the preceding example has a property named `id` of type `String`. The default serialization mechanism used in `MongoTemplate` (which backs the repository support) regards properties named `id` as the document ID. Currently, we support `String`, `ObjectId`, and `BigInteger` as id-types.
Please see <<mongo-template.id-handling, ID mapping>> for more information about on how the `id` field is handled in the mapping layer.
The following example shows how to create an interface that defines queries against the `Person` object from the preceding example:
.Basic repository interface to persist Person entities
====
@@ -93,7 +96,7 @@ class ApplicationConfig extends AbstractReactiveMongoConfiguration {
@Override
protected String getMappingBasePackage() {
return "com.oreilly.springdata.mongodb"
return "com.oreilly.springdata.mongodb";
}
}
----
@@ -117,6 +120,20 @@ public class PersonRepositoryTests {
----
====
WARNING: The `Page` return type (as in `Mono<Page>`) is not supported by reactive repositories.
It is possible to use `Pageable` in derived finder methods, to pass on `sort`, `limit` and `offset` parameters to the query to reduce load and network traffic.
The returned `Flux` will only emit data within the declared range.
.Limit and Offset with reactive repositories
====
[source,java]
----
Pageable page = PageRequest.of(1, 10, Sort.by("lastname"));
Flux<Person> persons = repository.findByFirstnameOrderByLastname("luke", page);
----
====
[[mongo.reactive.repositories.features]]
== Features
@@ -144,7 +161,7 @@ The following example shows how to define a `near` query that finds all persons
====
[source,java]
----
public interface PersonRepository extends ReactiveMongoRepository<Person, String>
public interface PersonRepository extends ReactiveMongoRepository<Person, String> {
// { 'location' : { '$near' : [point.x, point.y], '$maxDistance' : distance}}
Flux<Person> findByLocationNear(Point location, Distance distance);
@@ -179,7 +196,7 @@ Spring Data MongoDB supports geo-near queries, as the following example shows:
[source,java]
----
public interface PersonRepository extends ReactiveMongoRepository<Person, String>
public interface PersonRepository extends ReactiveMongoRepository<Person, String> {
// {'geoNear' : 'location', 'near' : [x, y] }
Flux<GeoResult<Person>> findByLocationNear(Point location);

View File

@@ -1,6 +1,181 @@
Spring Data MongoDB Changelog
=============================
Changes in version 2.1.18.RELEASE (2020-06-10)
----------------------------------------------
* DATAMONGO-2547 - java.lang.IllegalArgumentException: com.mongodb.client.MongoDatabase referenced from a method is not visible from class loader.
* DATAMONGO-2535 - Remove Travis CI.
* DATAMONGO-2532 - Release 2.1.18 (Lovelace SR18).
Changes in version 3.0.0.RC2 (2020-04-28)
-----------------------------------------
* DATAMONGO-2531 - Fix MongoClientSettings UUID configuration hook in MongoConfigurationSupport.
* DATAMONGO-2529 - EntityReader called with null argument.
* DATAMONGO-2523 - ParameterBindingJsonReader skips too many chars.
* DATAMONGO-2517 - Text search fails on entity with second constructor.
* DATAMONGO-2516 - Assert compatibility with MongoDB 4.4-rc0.
* DATAMONGO-2513 - ComparisonOperators.Eq#equalToValue doesn't work well with Lists.
* DATAMONGO-2510 - Use JDK 14 for Java.NEXT CI testing.
* DATAMONGO-2508 - Upgrade to MongoDB 4.0.2 Drivers.
* DATAMONGO-2507 - Add default method accepting CriteriaDefinition on ReactiveFindOperation.DistinctWithQuery.
* DATAMONGO-2506 - StringBasedAggregation should raise meaningful error when unsupported return type requested.
* DATAMONGO-2505 - Deferred Database retrieval from ReactiveMongoDatabaseFactory.
* DATAMONGO-2504 - TextCriteria Hashcode and equals.
* DATAMONGO-2503 - Release 3.0 RC2 (Neumann).
* DATAMONGO-2502 - Regression in Update property mapping.
Changes in version 2.2.7.RELEASE (2020-04-28)
---------------------------------------------
* DATAMONGO-2529 - EntityReader called with null argument.
* DATAMONGO-2523 - ParameterBindingJsonReader skips too many chars.
* DATAMONGO-2517 - Text search fails on entity with second constructor.
* DATAMONGO-2513 - ComparisonOperators.Eq#equalToValue doesn't work well with Lists.
* DATAMONGO-2506 - StringBasedAggregation should raise meaningful error when unsupported return type requested.
* DATAMONGO-2504 - TextCriteria Hashcode and equals.
* DATAMONGO-2502 - Regression in Update property mapping.
* DATAMONGO-2500 - Release 2.2.7 (Moore SR7).
Changes in version 2.1.17.RELEASE (2020-04-28)
----------------------------------------------
* DATAMONGO-2529 - EntityReader called with null argument.
* DATAMONGO-2497 - Update documentation regarding @Transient properties usage in the persistence constructor.
* DATAMONGO-2484 - Release 2.1.17 (Lovelace SR17).
* DATAMONGO-2300 - Can't read and convert DBRef when the type is Map.
Changes in version 3.0.0.RC1 (2020-03-31)
-----------------------------------------
* DATAMONGO-2501 - Upgrade to Querydsl 4.3.
* DATAMONGO-2498 - Upgrade to MongoDB 4.0.1 Drivers.
* DATAMONGO-2497 - Update documentation regarding @Transient properties usage in the persistence constructor.
* DATAMONGO-2492 - Release 3.0 RC1 (Neumann).
* DATAMONGO-2488 - KeyMapper.mapPropertyName does not work for nested arrays.
* DATAMONGO-2479 - More EntityCallback specializations.
* DATAMONGO-2477 - Disable auto-index creation by default.
* DATAMONGO-2475 - QueryDSL: $and and $or with more than two arguments in final query document.
* DATAMONGO-2416 - Add default methods accepting CriteriaDefinition on Fluent API.
* DATAMONGO-2300 - Can't read and convert DBRef when the type is Map.
* DATAMONGO-1026 - Joda, JSR-310 and ThreeTenBp converters are timezone-sensitive.
* DATAMONGO-931 - Add support for $redact operation.
* DATAMONGO-625 - GridFsOperations.createFile method should allow specification of _id.
Changes in version 2.2.6.RELEASE (2020-03-25)
---------------------------------------------
* DATAMONGO-2497 - Update documentation regarding @Transient properties usage in the persistence constructor.
* DATAMONGO-2488 - KeyMapper.mapPropertyName does not work for nested arrays.
* DATAMONGO-2485 - Release 2.2.6 (Moore SR6).
* DATAMONGO-2445 - Deprecate ReactiveGridFs methods using AsyncInputStream.
* DATAMONGO-2300 - Can't read and convert DBRef when the type is Map.
Changes in version 3.0.0.M4 (2020-03-11)
----------------------------------------
* DATAMONGO-2491 - Adapt to Mockito 3.3 changes.
* DATAMONGO-2489 - Upgrade to MongoDB Driver 4.0.
* DATAMONGO-2481 - Speed up build.
* DATAMONGO-2478 - NPE when using Query annotation and with sort and pageable.
* DATAMONGO-2476 - JsonParseException: JSON reader was expecting a value but found '}'.
* DATAMONGO-2474 - Upgrade to MongoDB Driver 4.0.0-rc0.
* DATAMONGO-2473 - Release 3.0 M4 (Neumann).
* DATAMONGO-2363 - Add support for $merge aggregation stage.
* DATAMONGO-2355 - Revise Abstract…MongoConfiguration to expose more bean detail and avoid proxying.
* DATAMONGO-2341 - Support shard key derivation.
Changes in version 2.2.5.RELEASE (2020-02-26)
---------------------------------------------
* DATAMONGO-2478 - NPE when using Query annotation and with sort and pageable.
* DATAMONGO-2476 - JsonParseException: JSON reader was expecting a value but found '}'.
* DATAMONGO-2464 - Fix code examples in reference documentation.
* DATAMONGO-2460 - @Field annotation behaviour changed.
* DATAMONGO-2459 - Update Documentation of Reactive Repositories to mention usage of PageRequest.
* DATAMONGO-2457 - Reference documentation: Text does not match with code example.
* DATAMONGO-2453 - Release 2.2.5 (Moore SR5).
* DATAMONGO-2406 - Allow Mono<Void> as return type for derived deleteBy queries.
* DATAMONGO-2079 - MappingMongoConverter cannot be proxied because it implements the package-private ValueResolver interface.
Changes in version 2.1.16.RELEASE (2020-02-26)
----------------------------------------------
* DATAMONGO-2464 - Fix code examples in reference documentation.
* DATAMONGO-2459 - Update Documentation of Reactive Repositories to mention usage of PageRequest.
* DATAMONGO-2457 - Reference documentation: Text does not match with code example.
* DATAMONGO-2452 - Release 2.1.16 (Lovelace SR16).
* DATAMONGO-2079 - MappingMongoConverter cannot be proxied because it implements the package-private ValueResolver interface.
Changes in version 3.0.0.M3 (2020-02-12)
----------------------------------------
* DATAMONGO-2470 - Adapt tests to AssertJ 3.15.0.
* DATAMONGO-2464 - Fix code examples in reference documentation.
* DATAMONGO-2462 - Move off deprecated EntityInstantiators.
* DATAMONGO-2461 - Fix Jenkins build.
* DATAMONGO-2460 - @Field annotation behaviour changed.
* DATAMONGO-2459 - Update Documentation of Reactive Repositories to mention usage of PageRequest.
* DATAMONGO-2457 - Reference documentation: Text does not match with code example.
* DATAMONGO-2456 - Release 3.0 M3 (Neumann).
* DATAMONGO-2449 - Add aggregation options parameters to @Aggregation annotation.
* DATAMONGO-2427 - Switch to 4.0-beta1 MongoDB driver.
* DATAMONGO-2417 - Typesafe Extension Function for ReactiveFindOperation.FindDistinct.
* DATAMONGO-2406 - Allow Mono<Void> as return type for derived deleteBy queries.
* DATAMONGO-2400 - Read/write converters not working.
* DATAMONGO-2365 - Parameter hint in Query#hint is not index name.
* DATAMONGO-2249 - Query hint leads to error when executed via reactive template.
* DATAMONGO-2079 - MappingMongoConverter cannot be proxied because it implements the package-private ValueResolver interface.
* DATAMONGO-1997 - Add support to return the single deleted item for a deleteBy query method.
Changes in version 3.0.0.M2 (2020-01-17)
----------------------------------------
* DATAMONGO-2454 - Release 3.0 M2 (Neumann).
Changes in version 3.0.0.M1 (2020-01-16)
----------------------------------------
* DATAMONGO-2451 - Value of sort direction converted to String for id fields (query, index creation).
* DATAMONGO-2450 - Bulk Operations do not support filterArray in update operations.
* DATAMONGO-2448 - Bump Version to 3.0.
* DATAMONGO-2447 - Upgrade MongoDB Drivers to 3.12.0 and 1.13.0.
* DATAMONGO-2444 - Update copyright years to 2020.
* DATAMONGO-2442 - Cond.thenValueOf(String fieldReference) does not concat fieldRef with "$" prefix.
* DATAMONGO-2440 - Unable to use MongoTemplate to perform query with 'in' condition by field annotated with @Field(targetType = FieldType.OBJECT_ID).
* DATAMONGO-2437 - Grouping after aggregation returns NULL _id when mapping to a class with compound key.
* DATAMONGO-2430 - Upgrade to mongo-java-driver 3.11.2.
* DATAMONGO-2423 - @NonNullApi restricts update with null.
* DATAMONGO-2418 - Application Context Doesn't start with @Query.
* DATAMONGO-2414 - ReactiveGridFsResource.getDownloadStream(…) hang if completion happens on event loop.
* DATAMONGO-2410 - Using BasicDBObject as an entity caused java.lang.ClassCastException in runtime.
* DATAMONGO-2409 - Extension Function ReactiveFindOperation.DistinctWithProjection.asType() has wrong return type.
* DATAMONGO-2403 - ReactiveStringBasedAggregation / AggregationUtils fails on NPE because source or value is null.
* DATAMONGO-2399 - Upgrade to mongo-java-driver 3.11.1.
* DATAMONGO-2394 - nearSphere query wrongly generated with radian parameter instead of meters.
* DATAMONGO-2393 - Reading large file from ReactiveGridFsTemplate causes a stackoverflow and the code to hang.
* DATAMONGO-2392 - Reading GridFS files written with old api and custom id fails on ReactiveGridFsTemplate.
* DATAMONGO-2390 - Add maxTimeMS to AggregationOptions.
* DATAMONGO-2388 - IndexOperations.getIndexInfo() fails for index that has partialFilterExpression containing DBRef.
* DATAMONGO-2385 - Unnecessary null checks in MongoConverters.
* DATAMONGO-2383 - Release 3.0 M1 (Neumann).
* DATAMONGO-2370 - Add support for $round aggregation expression.
* DATAMONGO-2331 - Add support for Aggregations in Update.
* DATAMONGO-2059 - Replace usage of deprecated collection.count() with collection.countDocuments().
* DATAMONGO-765 - Add support for paging and sorting on GridFSTemplate.
Changes in version 2.2.4.RELEASE (2020-01-15)
---------------------------------------------
* DATAMONGO-2451 - Value of sort direction converted to String for id fields (query, index creation).
* DATAMONGO-2450 - Bulk Operations do not support filterArray in update operations.
* DATAMONGO-2444 - Update copyright years to 2020.
* DATAMONGO-2442 - Cond.thenValueOf(String fieldReference) does not concat fieldRef with "$" prefix.
* DATAMONGO-2440 - Unable to use MongoTemplate to perform query with 'in' condition by field annotated with @Field(targetType = FieldType.OBJECT_ID).
* DATAMONGO-2432 - Release 2.2.4 (Moore SR4).
* DATAMONGO-2423 - @NonNullApi restricts update with null.
Changes in version 2.1.15.RELEASE (2020-01-15)
----------------------------------------------
* DATAMONGO-2444 - Update copyright years to 2020.
@@ -2839,3 +3014,16 @@ Repository

View File

@@ -1,4 +1,4 @@
Spring Data MongoDB 2.1.15
Spring Data MongoDB 2.1.18
Copyright (c) [2010-2019] Pivotal Software, Inc.
This product is licensed to you under the Apache License, Version 2.0 (the "License").
@@ -10,3 +10,6 @@ code for the these subcomponents is subject to the terms and
conditions of the subcomponent's license, as noted in the LICENSE file.