DATAJPA-391 - Added test case to show projections for manually defined queries.

This commit is contained in:
Oliver Gierke
2013-08-09 19:21:35 +02:00
parent 0ce929a429
commit fd8b7b6a00
2 changed files with 19 additions and 0 deletions

View File

@@ -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();

View File

@@ -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);
}