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 in @Query with escape statement #3040

Closed
MMaliszewski opened this issue Jun 26, 2023 · 1 comment
Closed

BadJpqlGrammarException in @Query with escape statement #3040

MMaliszewski opened this issue Jun 26, 2023 · 1 comment
Assignees
Labels
in: query-parser Everything related to parsing JPQL or SQL type: regression A regression from a previous release

Comments

@MMaliszewski
Copy link

Hi, I've found the following problem when using Spring Data JPA 3.1.1 with Hibernate 6.2.5.Final:

@Repository
@ApplicationScope
public interface SomeDao extends JpaRepository<SomeDbo, Long> {

  @Query("select t.name from SomeDbo t where t.name LIKE :name escape '\\'")
    List<String> findNamesLike(@Param("name") String name);

// ...
}

Which causes the exception:

BadJpqlGrammarException: Line 1:63 token recognition error at: ''\'; Bad JPQL grammar 
[select t.name from SomeDbo t where t.name LIKE :name escape '\']

This worked fine with Spring Data JPA 2.7.10 + Hibernate 5.6.14.Final. I don't see any Hibernate-related code in the stacktrace, so I assume that's the validation on the Spring side.

@spring-projects-issues spring-projects-issues added the status: waiting-for-triage An issue we've not yet triaged label Jun 26, 2023
@gregturn gregturn self-assigned this Jun 26, 2023
@gregturn gregturn added type: regression A regression from a previous release in: query-parser Everything related to parsing JPQL or SQL and removed status: waiting-for-triage An issue we've not yet triaged labels Jun 26, 2023
@gregturn gregturn added this to the 3.1.2 (2023.0.2) milestone Jun 26, 2023
gregturn added a commit that referenced this issue Jun 26, 2023
Hibernate HQL supports using a `\\` as the ESCAPE character so we need to support it in our custom parser.

See #3040
gregturn added a commit that referenced this issue Jun 26, 2023
Hibernate HQL supports using a `\\` as the ESCAPE character so we need to support it in our custom parser.

See #3040
gregturn added a commit that referenced this issue Jun 26, 2023
Hibernate HQL supports using a `\\` as the ESCAPE character so we need to support it in our custom parser.

See #3040
@gregturn
Copy link
Contributor

gregturn commented Jun 26, 2023

That's 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

No branches or pull requests

3 participants