Description
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