diff --git a/pom.xml b/pom.xml
index 10c1adf1bf..e0463fe37c 100644
--- a/pom.xml
+++ b/pom.xml
@@ -5,7 +5,7 @@
org.springframework.data
spring-data-mongodb-parent
- 3.2.0-SNAPSHOT
+ 3.2.0-GH-3474-SNAPSHOT
pom
Spring Data MongoDB
diff --git a/spring-data-mongodb-benchmarks/pom.xml b/spring-data-mongodb-benchmarks/pom.xml
index f0fbb601c8..18c9ffd535 100644
--- a/spring-data-mongodb-benchmarks/pom.xml
+++ b/spring-data-mongodb-benchmarks/pom.xml
@@ -7,7 +7,7 @@
org.springframework.data
spring-data-mongodb-parent
- 3.2.0-SNAPSHOT
+ 3.2.0-GH-3474-SNAPSHOT
../pom.xml
diff --git a/spring-data-mongodb-distribution/pom.xml b/spring-data-mongodb-distribution/pom.xml
index 1a17321782..e4c3d08189 100644
--- a/spring-data-mongodb-distribution/pom.xml
+++ b/spring-data-mongodb-distribution/pom.xml
@@ -14,7 +14,7 @@
org.springframework.data
spring-data-mongodb-parent
- 3.2.0-SNAPSHOT
+ 3.2.0-GH-3474-SNAPSHOT
../pom.xml
diff --git a/spring-data-mongodb/pom.xml b/spring-data-mongodb/pom.xml
index 0248517caf..816e51cc65 100644
--- a/spring-data-mongodb/pom.xml
+++ b/spring-data-mongodb/pom.xml
@@ -11,7 +11,7 @@
org.springframework.data
spring-data-mongodb-parent
- 3.2.0-SNAPSHOT
+ 3.2.0-GH-3474-SNAPSHOT
../pom.xml
diff --git a/spring-data-mongodb/src/main/java/org/springframework/data/mongodb/core/query/Criteria.java b/spring-data-mongodb/src/main/java/org/springframework/data/mongodb/core/query/Criteria.java
index 7f8ec91fe3..496e292a3f 100644
--- a/spring-data-mongodb/src/main/java/org/springframework/data/mongodb/core/query/Criteria.java
+++ b/spring-data-mongodb/src/main/java/org/springframework/data/mongodb/core/query/Criteria.java
@@ -124,7 +124,12 @@ public static Criteria byExample(Object example) {
}
/**
- * Static factory method to create a {@link Criteria} matching an example object.
+ * Static factory method to create a {@link Criteria} matching an example object.
+ * By default the {@link Example} uses typed matching restricting it to probe assignable types. For example, when
+ * sticking with the default type key ({@code _class}), the query has restrictions such as
+ * _class : { $in : [com.acme.Person] }
.
+ * To avoid the above mentioned type restriction use an {@link UntypedExampleMatcher} with
+ * {@link Example#of(Object, org.springframework.data.domain.ExampleMatcher)}.
*
* @param example must not be {@literal null}.
* @return new instance of {@link Criteria}.
diff --git a/spring-data-mongodb/src/main/java/org/springframework/data/mongodb/repository/MongoRepository.java b/spring-data-mongodb/src/main/java/org/springframework/data/mongodb/repository/MongoRepository.java
index 144bb23afa..24e87121ee 100644
--- a/spring-data-mongodb/src/main/java/org/springframework/data/mongodb/repository/MongoRepository.java
+++ b/spring-data-mongodb/src/main/java/org/springframework/data/mongodb/repository/MongoRepository.java
@@ -78,16 +78,31 @@ public interface MongoRepository extends PagingAndSortingRepository List insert(Iterable entities);
- /*
- * (non-Javadoc)
+ /**
+ * Returns all entities matching the given {@link Example}. In case no match could be found an empty {@link List} is
+ * returned.
+ * By default the {@link Example} uses typed matching restricting it to probe assignable types. For example, when
+ * sticking with the default type key ({@code _class}), the query has restrictions such as
+ * _class : { $in : [com.acme.Person] }
.
+ * To avoid the above mentioned type restriction use an {@link org.springframework.data.mongodb.core.query.UntypedExampleMatcher} with
+ * {@link Example#of(Object, org.springframework.data.domain.ExampleMatcher)}.
+ *
* @see org.springframework.data.repository.query.QueryByExampleExecutor#findAll(org.springframework.data.domain.Example)
*/
@Override
List findAll(Example example);
- /*
- * (non-Javadoc)
- * @see org.springframework.data.repository.query.QueryByExampleExecutor#findAll(org.springframework.data.domain.Example, org.springframework.data.domain.Sort)
+ /**
+ * Returns all entities matching the given {@link Example} applying the given {@link Sort}. In case no match could be
+ * found an empty {@link List} is returned.
+ * By default the {@link Example} uses typed matching restricting it to probe assignable types. For example, when
+ * sticking with the default type key ({@code _class}), the query has restrictions such as
+ * _class : { $in : [com.acme.Person] }
.
+ * To avoid the above mentioned type restriction use an {@link org.springframework.data.mongodb.core.query.UntypedExampleMatcher} with
+ * {@link Example#of(Object, org.springframework.data.domain.ExampleMatcher)}.
+ *
+ * @see org.springframework.data.repository.query.QueryByExampleExecutor#findAll(org.springframework.data.domain.Example,
+ * org.springframework.data.domain.Sort)
*/
@Override
List findAll(Example example, Sort sort);
diff --git a/spring-data-mongodb/src/main/java/org/springframework/data/mongodb/repository/ReactiveMongoRepository.java b/spring-data-mongodb/src/main/java/org/springframework/data/mongodb/repository/ReactiveMongoRepository.java
index ac9a8900f3..a9c62a50ae 100644
--- a/spring-data-mongodb/src/main/java/org/springframework/data/mongodb/repository/ReactiveMongoRepository.java
+++ b/spring-data-mongodb/src/main/java/org/springframework/data/mongodb/repository/ReactiveMongoRepository.java
@@ -64,4 +64,33 @@ public interface ReactiveMongoRepository extends ReactiveSortingRepositor
*/
Flux insert(Publisher entities);
+ /**
+ * Returns all entities matching the given {@link Example}. In case no match could be found an empty {@link Flux} is
+ * returned.
+ * By default the {@link Example} uses typed matching restricting it to probe assignable types. For example, when
+ * sticking with the default type key ({@code _class}), the query has restrictions such as
+ * _class : { $in : [com.acme.Person] }
.
+ * To avoid the above mentioned type restriction use an {@link org.springframework.data.mongodb.core.query.UntypedExampleMatcher} with
+ * {@link Example#of(Object, org.springframework.data.domain.ExampleMatcher)}.
+ *
+ * @see org.springframework.data.repository.query.ReactiveQueryByExampleExecutor#findAll(org.springframework.data.domain.Example)
+ */
+ @Override
+ Flux findAll(Example example);
+
+ /**
+ * Returns all entities matching the given {@link Example} applying the given {@link Sort}. In case no match could be
+ * found an empty {@link Flux} is returned.
+ * By default the {@link Example} uses typed matching restricting it to probe assignable types. For example, when
+ * sticking with the default type key ({@code _class}), the query has restrictions such as
+ * _class : { $in : [com.acme.Person] }
.
+ * To avoid the above mentioned type restriction use an {@link org.springframework.data.mongodb.core.query.UntypedExampleMatcher} with
+ * {@link Example#of(Object, org.springframework.data.domain.ExampleMatcher)}.
+ *
+ * @see org.springframework.data.repository.query.ReactiveQueryByExampleExecutor#findAll(org.springframework.data.domain.Example,
+ * org.springframework.data.domain.Sort)
+ */
+ @Override
+ Flux findAll(Example example, Sort sort);
+
}
diff --git a/src/main/asciidoc/reference/query-by-example.adoc b/src/main/asciidoc/reference/query-by-example.adoc
index d1f5ce5aaf..342ade291a 100644
--- a/src/main/asciidoc/reference/query-by-example.adoc
+++ b/src/main/asciidoc/reference/query-by-example.adoc
@@ -97,3 +97,10 @@ Query query = new Query(new Criteria().alike(example));
List result = template.find(query, Person.class);
----
====
+
+[NOTE]
+====
+`UntypedExampleMatcher` is likely the right choice for you if you are storing different entities within a single collection or opted out of writing <>.
+
+Also, keep in mind that using `@TypeAlias` requires eager initialization of the `MappingContext`. To do so, configure `initialEntitySet` to to ensure proper alias resolution for read operations.
+====