Description
Andriy Redko opened DATAJPA-1652 and commented
Since the Lovelace release train, the usage of '||' along named parameters in custom queries ends up with Caused by: org.hibernate.QueryException: Named parameter [..] not set
exception. The query is parsed and works as expected in Ingalls and before.
Example:
@Query(value = "SELECT u FROM User u WHERE u.lastname LIKE '%'||:name||'%'")
Page<User> findByNamedQueryWithLike(@Param("name") String name, Pageable page);
The pipes (||) are supported by some SQL dialects (and HSQL) in order to support concatenation of multiple values, alternatively to concat
function.
The cause: the identifier pattern (declared in QueryUtils) has changed in Lovelace and above, instead of capturing 'name', it captures 'name||', leading to:
Caused by: org.hibernate.QueryException: Named parameter [name] not set
at org.hibernate.query.internal.QueryParameterBindingsImpl.verifyParametersBound(QueryParameterBindingsImpl.java:251)
at org.hibernate.query.internal.AbstractProducedQuery.beforeQuery(AbstractProducedQuery.java:1313)
at org.hibernate.query.internal.AbstractProducedQuery.list(AbstractProducedQuery.java:1412)
at org.hibernate.query.Query.getResultList(Query.java:146)
Affects: 2.1.14 (Lovelace SR14), 2.2.3 (Moore SR3)
Referenced from: pull request #405
Backported to: 2.2.4 (Moore SR4), 2.1.15 (Lovelace SR15)