Verify that projections work with subqueries.
Interface-based projections used to NOT work when the query had a subquery in it. But with the new query parser, it already handles it. So this simply captures the test providing that corner case. See #2008 Original Pull Request: #420
This commit is contained in:
@@ -315,4 +315,15 @@ class UserRepositoryFinderTests {
|
||||
void executesNamedQueryWithConstructorExpression() {
|
||||
userRepository.findByNamedQueryWithConstructorExpression();
|
||||
}
|
||||
|
||||
@Test // DATAJPA-1713, GH-2008
|
||||
public void selectProjectionWithSubselect() {
|
||||
|
||||
List<UserRepository.NameOnly> dtos = userRepository.findProjectionBySubselect();
|
||||
|
||||
assertThat(dtos).flatExtracting(UserRepository.NameOnly::getFirstname) //
|
||||
.containsExactly("Dave", "Carter", "Oliver August");
|
||||
assertThat(dtos).flatExtracting(UserRepository.NameOnly::getLastname) //
|
||||
.containsExactly("Matthews", "Beauford", "Matthews");
|
||||
}
|
||||
}
|
||||
|
||||
@@ -718,6 +718,10 @@ public interface UserRepository extends JpaRepository<User, Integer>, JpaSpecifi
|
||||
nativeQuery = true)
|
||||
int mergeNativeStatement();
|
||||
|
||||
// DATAJPA-1713, GH-2008
|
||||
@Query("select u from User u where u.firstname >= (select Min(u0.firstname) from User u0)")
|
||||
List<NameOnly> findProjectionBySubselect();
|
||||
|
||||
interface RolesAndFirstname {
|
||||
|
||||
String getFirstname();
|
||||
|
||||
Reference in New Issue
Block a user