Skip to content

Commit 6270e86

Browse files
committed
DATAMONGO-1245 - Adopt QBE API refactoring.
Adopt changes from query by example API refactoring. Related ticket: DATACMNS-810.
1 parent 9e18a54 commit 6270e86

File tree

8 files changed

+302
-190
lines changed

8 files changed

+302
-190
lines changed

spring-data-mongodb/src/main/java/org/springframework/data/mongodb/core/MongoOperations.java

+32
Original file line numberDiff line numberDiff line change
@@ -19,6 +19,7 @@
1919
import java.util.List;
2020
import java.util.Set;
2121

22+
import org.springframework.data.domain.Example;
2223
import org.springframework.data.geo.GeoResults;
2324
import org.springframework.data.mongodb.core.BulkOperations.BulkMode;
2425
import org.springframework.data.mongodb.core.aggregation.Aggregation;
@@ -56,6 +57,7 @@
5657
* @author Chuong Ngo
5758
* @author Christoph Strobl
5859
* @author Thomas Darimont
60+
* @author Mark Paluch
5961
*/
6062
public interface MongoOperations {
6163

@@ -628,6 +630,36 @@ <T> MapReduceResults<T> mapReduce(Query query, String inputCollectionName, Strin
628630
*/
629631
<T> T findById(Object id, Class<T> entityClass, String collectionName);
630632

633+
/**
634+
* Map the results of a Query-by-Example query onto the given {@code probe} class. The collection is determined from the {@code probe} type.
635+
* <p/>
636+
* The objects are converted from the MongoDB native representation using an instance of {@see MongoConverter}. Unless
637+
* configured otherwise, an instance of MappingMongoConverter will be used.
638+
* <p/>
639+
* The query is constructed from the {@code probe}.
640+
*
641+
* @param probe the probe to be used for the Example, must not be {@literal null}.
642+
* @param <S>
643+
* @param <T>
644+
* @return the List of converted objects
645+
*/
646+
<S extends T, T> List<T> findByExample(S probe);
647+
648+
/**
649+
* Map the results of a Query-by-Example query onto the given {@link Example#getProbeType()} class. The collection is determined from the {@link Example#getProbeType()}.
650+
* <p/>
651+
* The objects are converted from the MongoDB native representation using an instance of {@see MongoConverter}. Unless
652+
* configured otherwise, an instance of MappingMongoConverter will be used.
653+
* <p/>
654+
* The query is constructed from the {@link Example}.
655+
*
656+
* @param example the example, must not be {@literal null}.
657+
* @param <S>
658+
* @param <T>
659+
* @return the List of converted objects
660+
*/
661+
<S extends T, T> List<T> findByExample(Example<S> example);
662+
631663
/**
632664
* Triggers <a href="http://docs.mongodb.org/manual/reference/method/db.collection.findAndModify/">findAndModify
633665
* <a/> to apply provided {@link Update} on documents matching {@link Criteria} of given {@link Query}.

0 commit comments

Comments
 (0)