Skip to content

EQL parser fails to parse LIKE with ESCAPE clause #3873

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
0lgakuzmenko opened this issue May 8, 2025 · 3 comments
Closed

EQL parser fails to parse LIKE with ESCAPE clause #3873

0lgakuzmenko opened this issue May 8, 2025 · 3 comments
Assignees
Labels
type: regression A regression from a previous release

Comments

@0lgakuzmenko
Copy link

Hi!

EqlEscape_jpa_2_4_19_working.zip
EqlEscape_jpa_3_4_5_not_working.zip

We're moving our project to spring-boot and newer spring. We're limited to use EclipseLink, so can't move to Hibernate.
Previously we used spring-data-jpa of 2.4.9 version and everything worked fine. Please find EqlEscape_jpa_2_4_19_working.zip sample attached.
Now we're trying to migrate to spring-boot and update spring-data-jpa to 3.4.5 version. Please find EqlEscape_jpa_3_4_5_not_working.zip sample attached. Having rest of the code the same producing the following exception on 3.4.5:

Caused by: org.springframework.data.jpa.repository.query.BadJpqlGrammarException: At 1:72 and token ''\'', mismatched input ''\'', expecting one of the following tokens: '?', ':', CHARACTER; Bad EQL grammar [SELECT e FROM SampleEntity e WHERE LOWER(e.label) LIKE LOWER(?1) ESCAPE '\']
	at org.springframework.data.jpa.repository.query.BadJpqlGrammarErrorListener.syntaxError(BadJpqlGrammarErrorListener.java:53) ~[spring-data-jpa-3.4.5.jar:3.4.5]

when change ESCAPE character from \ to any other symbol, no exception is thrown.

I've debugged a bit and found out that spring-data-jpa of 2.4.9 version's org/springframework/data/jpa/repository/query/StringQuery.java doesn't have JpaQueryEnhancer and Hql/Eql/Jpql parsers, and with spring-data-jpa to 3.4.5 version at org/springframework/data/jpa/repository/query/StringQuery.java at line 98 there is added:
this.queryEnhancer = QueryEnhancerFactory.forQuery(this);
that leads to EqlParser and fails when EclipseLink is used.
If comment out:

    configurations.each {
        // if comment these exclusions out, spring data jpa uses HqlParse instead of
        // EqlParse and then everything works as expected
        it.exclude(module: 'hibernate-commons-annotations')
        it.exclude(module: 'hibernate-core')
        it.exclude(module: 'hibernate-envers')
    } 

in provided EqlEscape_jpa_3_4_5_not_working.zip sample's gradle file, then HqlParser is used and issue doesn't occur.

I found similar issues that seem to be resolved:
#2955
#3040

Thank you for your help!

Regards,
Olga

@spring-projects-issues spring-projects-issues added the status: waiting-for-triage An issue we've not yet triaged label May 8, 2025
@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 9, 2025
@mp911de mp911de self-assigned this May 9, 2025
@mp911de mp911de changed the title EqlParser: mismatched input ''\'' BadJpqlGrammarException exception for queries with LIKE and ESCAPE ''\'' when EclipseLink is used EQL parser fails to parse LIKE with ESCAPE clause May 12, 2025
@mp911de mp911de added this to the 3.4.6 (2024.1.6) milestone May 12, 2025
@mp911de
Copy link
Member

mp911de commented May 12, 2025

With version 3.4, we introduced eager parsing and that is why all statements are parsed and validated on startup. Previously (especially with version 3.3) the parser shortcomings haven't surfaced because of deferred parsing.

@0lgakuzmenko
Copy link
Author

0lgakuzmenko commented May 12, 2025

Thank you! Could you please provide an ETA for 3.3.12 and 3.4.6 to be released?

@mp911de
Copy link
Member

mp911de commented May 12, 2025

These are scheduled for Friday, see also https://spring.io/projects#release-calendar for the full release calendar.

mp911de added a commit that referenced this issue May 13, 2025
mp911de added a commit that referenced this issue May 15, 2025
mp911de added a commit that referenced this issue May 16, 2025
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
type: regression A regression from a previous release
Projects
None yet
Development

No branches or pull requests

3 participants