#436 - Add Redis QbE (Query by Example) example.
This commit is contained in:
@@ -21,12 +21,13 @@ import org.springframework.data.domain.Page;
|
||||
import org.springframework.data.domain.Pageable;
|
||||
import org.springframework.data.geo.Circle;
|
||||
import org.springframework.data.repository.CrudRepository;
|
||||
import org.springframework.data.repository.query.QueryByExampleExecutor;
|
||||
|
||||
/**
|
||||
* @author Christoph Strobl
|
||||
* @author Mark Paluch
|
||||
*/
|
||||
interface PersonRepository extends CrudRepository<Person, String> {
|
||||
interface PersonRepository extends CrudRepository<Person, String>, QueryByExampleExecutor<Person> {
|
||||
|
||||
List<Person> findByLastname(String lastname);
|
||||
|
||||
|
||||
@@ -33,6 +33,7 @@ import org.junit.rules.RuleChain;
|
||||
import org.junit.runner.RunWith;
|
||||
import org.springframework.beans.factory.annotation.Autowired;
|
||||
import org.springframework.boot.test.context.SpringBootTest;
|
||||
import org.springframework.data.domain.Example;
|
||||
import org.springframework.data.domain.Page;
|
||||
import org.springframework.data.domain.PageRequest;
|
||||
import org.springframework.data.domain.Pageable;
|
||||
@@ -144,6 +145,21 @@ public class PersonRepositoryTests {
|
||||
assertThat(aryaAndJon).containsOnly(arya, jon);
|
||||
}
|
||||
|
||||
/**
|
||||
* Find entities by {@link Example Query by Example}.
|
||||
*/
|
||||
@Test
|
||||
public void findByQueryByExample() {
|
||||
|
||||
flushTestUsers();
|
||||
|
||||
Example<Person> example = Example.of(new Person(null, "stark", null));
|
||||
|
||||
Iterable<Person> starks = repository.findAll(example);
|
||||
|
||||
assertThat(starks).contains(arya, eddard).doesNotContain(jon);
|
||||
}
|
||||
|
||||
/**
|
||||
* Find entities in range defined by {@link Pageable}.
|
||||
*/
|
||||
|
||||
Reference in New Issue
Block a user