Hi,
I am getting the following exception after upgrading my dependencies:
org.hibernate.QueryException:
Named parameter not bound : types_1
The exception occurs while executing a paginated query. The stack trace goes through:
org.springframework.data.jpa.repository.query.JpaQueryExecution$PagedExecution.count
The relevant versions are:
Working:
Spring Boot 3.1.2
Spring Data JPA 3.1.2
Hibernate 6.2.6.Final
Failing:
Spring Boot 3.1.12
Spring Data JPA 3.1.12
Hibernate 6.2.25.Final
When I revert to the older Spring Boot/Hibernate dependency versions, the issue does not occur.
The query contains an optional collection parameter similar to:
AND (
COALESCE(:types) IS NULL
OR entity.type IN (:types)
)
where types is a Set<String>.
The query works with Hibernate 6.2.6.Final but fails with Hibernate 6.2.25.Final.
I understand that collection parameters are normally used with:
entity.type IN (:types)
I also found discussions indicating that list parameters should not be used with COALESCE() or IS NULL.
My questions are:
-
Is using a collection-valued parameter with
COALESCE()unsupported in Hibernate 6.x? -
Were there any relevant changes between Hibernate 6.2.6.Final and 6.2.25.Final regarding collection parameter binding?
-
Could this behavior be related to the pagination count query?
-
Could the change in Spring Boot / Spring Data JPA versions also be involved?
-
What is the recommended way to handle an optional collection parameter in JPQL?
I am trying to determine whether this is caused by a change in Hibernate, Spring Data JPA, or simply an unsupported query pattern that happened to work with the older dependency versions.
Thanks!