Skip to content

BadJpqlGrammarException in @Query with escape statement #3040

Closed
@MMaliszewski

Description

@MMaliszewski

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.

Metadata

Metadata

Assignees

Labels

in: query-parserEverything related to parsing JPQL or SQLtype: regressionA regression from a previous release

Type

No type

Projects

No projects

Relationships

None yet

Development

No branches or pull requests

Issue actions