-
Notifications
You must be signed in to change notification settings - Fork 1.5k
Invalid sort alias with subquery and sorted page request #2581
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Comments
Okay, I've captured this scenario in a test method inside Spring Data JPA. @ExtendWith(SpringExtension.class)
@ContextConfiguration
public class PageRequestSortQueryDoesntWorkIntegrationTests {
@Autowired ThisRepository thisRepository;
@Autowired ThatRepository thatRepository;
@Test
void test() {
That that = thatRepository.save(new That());
thisRepository.demo(that, PageRequest.of(0, 1, Sort.by("id")));
}
@Entity
@Data
@NoArgsConstructor(access = AccessLevel.PROTECTED)
@AllArgsConstructor
static class This {
@Id
@GeneratedValue private Long id;
}
@Entity
@Data
@NoArgsConstructor(access = AccessLevel.PROTECTED)
@AllArgsConstructor
static class That {
@Id
@GeneratedValue private Long id;
}
interface ThisRepository extends JpaRepository<This, Long> {
@Query("""
select f from This f
where exists (
select 1 from That b
where b = ?1
)
""")
Page<This> demo(That that, Pageable pageable);
}
interface ThatRepository extends JpaRepository<That, Long> {
}
@Configuration
@ImportResource("classpath:infrastructure.xml")
@EnableJpaRepositories(considerNestedRepositories = true,
basePackageClasses = CustomNonBindableJpaParametersIntegrationTests.ProductRepository.class, //
includeFilters = @ComponentScan.Filter(value = { ThisRepository.class, ThatRepository.class },
type = FilterType.ASSIGNABLE_TYPE))
static class Config {
}
} There is no Spring Boot. Just plain old Spring Framwork and Spring Data JPA. And the error I'm seeing is this:
And to be honest, I don't see where the outer select correlates with the inner select. The inner select matches on the |
Thanks for your response. When I was debugging the issue I found the subquery parenthesis weren't being identified and removed. What do you think the PR I submitted? |
Good day @c-fraser , @gregturn , I also encountered this error while using Given Chris' fix of using May we know when's the earliest release date of the fix? Thank you! |
@edoswaldgo This fix was backported to |
PR #2516 appears to not completely fix the issue described in issue #2518.
Using Spring Boot 2.7.1 with the models...
and the repositories...
the execution of...
results in...
The text was updated successfully, but these errors were encountered: