|
21 | 21 | import static org.springframework.data.domain.Example.*;
|
22 | 22 | import static org.springframework.data.domain.ExampleMatcher.*;
|
23 | 23 | import static org.springframework.data.domain.Sort.Direction.*;
|
24 |
| -import static org.springframework.data.jpa.domain.Specifications.not; |
25 | 24 | import static org.springframework.data.jpa.domain.Specifications.*;
|
| 25 | +import static org.springframework.data.jpa.domain.Specifications.not; |
26 | 26 | import static org.springframework.data.jpa.domain.sample.UserSpecifications.*;
|
27 | 27 |
|
28 | 28 | import java.util.ArrayList;
|
|
33 | 33 | import java.util.List;
|
34 | 34 | import java.util.Set;
|
35 | 35 | import java.util.function.Consumer;
|
| 36 | +import java.util.stream.Collectors; |
36 | 37 | import java.util.stream.Stream;
|
37 | 38 |
|
38 | 39 | import javax.persistence.EntityManager;
|
|
55 | 56 | import org.springframework.dao.InvalidDataAccessApiUsageException;
|
56 | 57 | import org.springframework.data.domain.Example;
|
57 | 58 | import org.springframework.data.domain.ExampleMatcher;
|
58 |
| -import org.springframework.data.domain.ExampleMatcher.*; |
59 | 59 | import org.springframework.data.domain.Page;
|
60 | 60 | import org.springframework.data.domain.PageImpl;
|
61 | 61 | import org.springframework.data.domain.PageRequest;
|
|
64 | 64 | import org.springframework.data.domain.Sort;
|
65 | 65 | import org.springframework.data.domain.Sort.Direction;
|
66 | 66 | import org.springframework.data.domain.Sort.Order;
|
| 67 | +import org.springframework.data.domain.ExampleMatcher.*; |
67 | 68 | import org.springframework.data.jpa.domain.Specification;
|
68 | 69 | import org.springframework.data.jpa.domain.sample.Address;
|
69 | 70 | import org.springframework.data.jpa.domain.sample.Role;
|
@@ -2142,7 +2143,27 @@ public void excutesPagedSpecificationSettingAnOrder() {
|
2142 | 2143 | public void queryProvidesCorrectNumberOfParametersForNativeQuery() {
|
2143 | 2144 |
|
2144 | 2145 | Query query = em.createNativeQuery("select 1 from User where firstname=? and lastname=?");
|
2145 |
| - assertThat(query.getParameters(),hasSize(2)); |
| 2146 | + assertThat(query.getParameters(), hasSize(2)); |
| 2147 | + } |
| 2148 | + |
| 2149 | + @Test // DATAJPA-1185 |
| 2150 | + public void dynamicProjectionReturningStream() { |
| 2151 | + |
| 2152 | + flushTestUsers(); |
| 2153 | + |
| 2154 | + Stream<User> users = repository.findAsStreamByFirstnameLike("%O%", User.class); |
| 2155 | + |
| 2156 | + assertThat(users.collect(Collectors.toList()), hasSize(1)); |
| 2157 | + } |
| 2158 | + |
| 2159 | + @Test // DATAJPA-1185 |
| 2160 | + public void dynamicProjectionReturningList() { |
| 2161 | + |
| 2162 | + flushTestUsers(); |
| 2163 | + |
| 2164 | + List<User> users = repository.findAsListByFirstnameLike("%O%", User.class); |
| 2165 | + |
| 2166 | + assertThat(users, hasSize(1)); |
2146 | 2167 | }
|
2147 | 2168 |
|
2148 | 2169 | private Page<User> executeSpecWithSort(Sort sort) {
|
|
0 commit comments