DATAJPA-391 - Added test case to show projections for manually defined queries.
This commit is contained in:
@@ -1080,6 +1080,19 @@ public class UserRepositoryTests {
|
||||
assertThat(repository.findAll((Iterable<Integer>) null), is(emptyIterable()));
|
||||
}
|
||||
|
||||
/**
|
||||
* @see DATAJPA-391
|
||||
*/
|
||||
@Test
|
||||
public void executesManuallyDefinedQueryWithFieldProjection() {
|
||||
|
||||
flushTestUsers();
|
||||
List<String> lastname = repository.findFirstnamesByLastname("Matthews");
|
||||
|
||||
assertThat(lastname, hasSize(1));
|
||||
assertThat(lastname, hasItem("Dave"));
|
||||
}
|
||||
|
||||
private Page<User> executeSpecWithSort(Sort sort) {
|
||||
|
||||
flushTestUsers();
|
||||
|
||||
@@ -264,4 +264,10 @@ public interface UserRepository extends JpaRepository<User, Integer>, JpaSpecifi
|
||||
* @see DATAJPA-231
|
||||
*/
|
||||
int countUsersByFirstname(String firstname);
|
||||
|
||||
/**
|
||||
* @see DATAJPA-391
|
||||
*/
|
||||
@Query("select u.firstname from User u where u.lastname = ?1")
|
||||
List<String> findFirstnamesByLastname(String lastname);
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user