public interface PersonRepository extends QueryByExampleExecutor<Person> {
}
public class PersonService {
@Autowired PersonRepository personRepository;
public List<Person> findPeople(Person probe) {
return personRepository.findAll(Example.of(probe));
}
}
An Example
containing an untyped ExampleSpec
uses the Repository type and its collection name. Typed ExampleSpec
use their type as result type and the collection name from the Repository.
Note
|
When including null values in the ExampleSpec Spring Data Mongo uses embedded document matching instead of dot notation property matching. This forces exact document matching for all property values and the property order in the embedded document.
|
Spring Data MongoDB provides support for the following matching options:
StringMatcher
options
Matching | Logical result |
---|---|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|