Question

I'm trying to make this simple JPA query working:

@Query("SELECT p FROM PersonImpl p WHERE p.customerReference LIKE :query ESCAPE '\\\\'")
public Page<Person> findByQuery(@Param("query") String query, Pageable pageable);

But upon application startup I get exception:

java.lang.IllegalArgumentException: Illegal like pattern :query!
at org.springframework.data.jpa.repository.query.StringQuery.getLikeTypeFrom(StringQuery.java:205)
at org.springframework.data.jpa.repository.query.StringQuery.parseLikeBindings(StringQuery.java:155)

When I change the :query param into a string literal, for eg. 'foobar', then it's fine. Does anyone know what's the issue here?

Was it helpful?

Solution

Apparently it was a bug in Spring Data JPA 1.3.1. After upgrading to 1.3.4 it works as expected.

Licensed under: CC-BY-SA with attribution
Not affiliated with StackOverflow
scroll top