|
42 | 42 | import org.junit.jupiter.params.ParameterizedTest;
|
43 | 43 | import org.junit.jupiter.params.provider.Arguments;
|
44 | 44 | import org.junit.jupiter.params.provider.MethodSource;
|
45 |
| - |
46 | 45 | import org.springframework.beans.factory.annotation.Autowired;
|
47 | 46 | import org.springframework.beans.factory.config.PropertiesFactoryBean;
|
48 | 47 | import org.springframework.context.ApplicationListener;
|
|
52 | 51 | import org.springframework.core.io.ClassPathResource;
|
53 | 52 | import org.springframework.dao.IncorrectResultSizeDataAccessException;
|
54 | 53 | import org.springframework.data.annotation.Id;
|
55 |
| -import org.springframework.data.domain.Example; |
56 |
| -import org.springframework.data.domain.ExampleMatcher; |
57 |
| -import org.springframework.data.domain.Limit; |
58 |
| -import org.springframework.data.domain.Page; |
59 |
| -import org.springframework.data.domain.PageRequest; |
60 |
| -import org.springframework.data.domain.Pageable; |
61 |
| -import org.springframework.data.domain.ScrollPosition; |
62 |
| -import org.springframework.data.domain.Slice; |
63 |
| -import org.springframework.data.domain.Sort; |
64 |
| -import org.springframework.data.domain.Window; |
| 54 | +import org.springframework.data.domain.*; |
65 | 55 | import org.springframework.data.jdbc.core.mapping.AggregateReference;
|
66 | 56 | import org.springframework.data.jdbc.repository.query.Modifying;
|
67 | 57 | import org.springframework.data.jdbc.repository.query.Query;
|
@@ -923,6 +913,19 @@ void findAllByExamplePageable(Pageable pageRequest, int size, int totalPages, Li
|
923 | 913 | }
|
924 | 914 | }
|
925 | 915 |
|
| 916 | + @Test |
| 917 | + void findByExampleWithCollection() { |
| 918 | + |
| 919 | + List<Root> roots = rootRepository.saveAll(List.of(createRoot("one"), createRoot("two"))); |
| 920 | + |
| 921 | + Example<Root> example = Example |
| 922 | + .of(new Root(null, "one", null, List.of(new Intermediate(null, "peter", null, null)))); |
| 923 | + |
| 924 | + Iterable<Root> result = rootRepository.findAll(example); |
| 925 | + |
| 926 | + assertThat(result).contains(roots.get(0)); |
| 927 | + } |
| 928 | + |
926 | 929 | public static Stream<Arguments> findAllByExamplePageableSource() {
|
927 | 930 | return Stream.of( //
|
928 | 931 | Arguments.of(PageRequest.of(0, 3), 3, 34, Arrays.asList("3", "4", "100")), //
|
@@ -1509,7 +1512,7 @@ interface DummyEntityRepository extends CrudRepository<DummyEntity, Long>, Query
|
1509 | 1512 | List<DummyEntity> findByBytes(byte[] bytes);
|
1510 | 1513 | }
|
1511 | 1514 |
|
1512 |
| - interface RootRepository extends ListCrudRepository<Root, Long> { |
| 1515 | + interface RootRepository extends ListCrudRepository<Root, Long>, QueryByExampleExecutor<Root> { |
1513 | 1516 | List<Root> findAllByOrderByIdAsc();
|
1514 | 1517 | }
|
1515 | 1518 |
|
|
0 commit comments