Skip to content
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

BadJpqlGrammarException with latest relase when using ORDER BY NULLS LAST #2962

Closed
mavarazo opened this issue May 22, 2023 · 2 comments
Closed
Assignees
Labels
in: query-parser Everything related to parsing JPQL or SQL type: regression A regression from a previous release

Comments

@mavarazo
Copy link

mavarazo commented May 22, 2023

We faced today with the latest release from Spring Boot 3.1.0 an issue with a query which uses to order by nulls last.

@Query("select a, case when a.geaendertAm is null then a.erstelltAm else a.geaendertAm end as mutationAm from Element a" +
        " where a.erstelltDurch = :#{#erstelltDurch}" +
        " order by mutationAm desc nulls last")
    List<Element> findAllByErstelltDurchOrderByGeaendertAmDesc(String erstelltDurch);

The issue we have:

org.springframework.dao.InvalidDataAccessApiUsageException: org.springframework.data.jpa.repository.query.BadJpqlGrammarException: Line 1:378 mismatched input 'NULLS' expecting {<EOF>, ',', EXCEPT, FETCH, INTERSECT, LIMIT, OFFSET, UNION}; Bad JPQL grammar [select a, case when a.geaendertAm is null then a.erstelltAm else a.geaendertAm end as mutationAm from Element a where a.erstelltDurch = :__$synthetic$__1 order by mutationAm desc NULLS LAST]

Thanks for any advice to fix the issue

@spring-projects-issues spring-projects-issues added the status: waiting-for-triage An issue we've not yet triaged label May 22, 2023
@mp911de mp911de added type: regression A regression from a previous release and removed status: waiting-for-triage An issue we've not yet triaged labels May 22, 2023
@mp911de mp911de added the in: query-parser Everything related to parsing JPQL or SQL label May 22, 2023
@gregturn
Copy link
Contributor

Looks like we didn't implement all the right parts regarding ORDER BY the NULLS (FIRST | LAST) options.

gregturn added a commit that referenced this issue May 22, 2023
gregturn added a commit that referenced this issue May 22, 2023
@gregturn gregturn linked a pull request May 22, 2023 that will close this issue
gregturn added a commit that referenced this issue May 22, 2023
gregturn added a commit that referenced this issue May 22, 2023
@gregturn gregturn added this to the 3.2 M1 (2023.1.0) milestone May 22, 2023
gregturn added a commit that referenced this issue May 22, 2023
gregturn added a commit that referenced this issue May 22, 2023
@gregturn
Copy link
Contributor

Merged to main and backported to 3.1.x.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
in: query-parser Everything related to parsing JPQL or SQL type: regression A regression from a previous release
Projects
None yet
Development

Successfully merging a pull request may close this issue.

4 participants