Skip to content

Error when using reserved words in JPQL query for entity field names and packages #3832

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

Closed
DmitryBelousov1992 opened this issue Apr 8, 2025 · 2 comments
Assignees
Labels
type: bug A general bug

Comments

@DmitryBelousov1992
Copy link

DmitryBelousov1992 commented Apr 8, 2025

The following errors were found during migration to springboot 3.x.:

BadJpqlGrammarException: Line 1:43 no viable alternative at input 'ie.object'; Bad JPQL grammar [select ie from ItemExample ie left join ie.object io where io.externalId = :externalId]
for
@query("select ie from ItemExample ie left join ie.object io where io.externalId = :externalId")
Page findPageByExternalId(@param("externalId") String externalId, Pageable pageable);
BadJpqlGrammarException: Line 1:63 no viable alternative at input 'ie.status=com.app.domain.object'; Bad JPQL grammar [select ie from ItemExample ie where ie.status = com.app.domain.object.Status.UP]
for
@query("select ie from ItemExample ie where ie.status = com.app.domain.object.Status.UP")
Page findByStatusUp(Pageable pageable);

I am attaching an example springboot 3.x application with detailed comments and examples of errors and workarounds found in the file com.app.repo.ItemExampleRepository.
https://github.com/DmitryBelousov1992/SpringReservedWordsExampleErrors.git

@spring-projects-issues spring-projects-issues added the status: waiting-for-triage An issue we've not yet triaged label Apr 8, 2025
@DmitryBelousov1992 DmitryBelousov1992 changed the title Error when using reserved words (JPQL aggregate functions) in entity field names and packages Error when using reserved words in JPQL query for entity field names and packages Apr 8, 2025
@mp911de mp911de added type: bug A general bug and removed status: waiting-for-triage An issue we've not yet triaged labels Apr 9, 2025
@mp911de
Copy link
Member

mp911de commented Apr 9, 2025

This is to some extent a duplicate of #3829. However, for the plain JPQL parser, the issue has persisted and we fixed that problem when neither Hibernate nor Eclipselink are on the classpath.

mp911de added a commit that referenced this issue Apr 9, 2025
@mp911de mp911de closed this as completed in 4f99584 Apr 9, 2025
mp911de added a commit that referenced this issue Apr 9, 2025
@mp911de mp911de added this to the 3.3.11 (2024.0.11) milestone Apr 9, 2025
@mp911de mp911de self-assigned this Apr 9, 2025
@DmitryBelousov1992
Copy link
Author

Thank you so much!

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
type: bug A general bug
Projects
None yet
Development

No branches or pull requests

3 participants