[JIRA] (HHH-16828) CriteriaBuilder.equal(Expression any, null object): QueryException: Ordinal parameter not bound
by Michael Musenbrock (JIRA)
Michael Musenbrock ( https://hibernate.atlassian.net/secure/ViewProfile.jspa?accountId=712020%... ) *created* an issue
Hibernate ORM ( https://hibernate.atlassian.net/browse/HHH?atlOrigin=eyJpIjoiNDkzYzBmY2Nj... ) / Bug ( https://hibernate.atlassian.net/browse/HHH-16828?atlOrigin=eyJpIjoiNDkzYz... ) HHH-16828 ( https://hibernate.atlassian.net/browse/HHH-16828?atlOrigin=eyJpIjoiNDkzYz... ) CriteriaBuilder.equal(Expression any, null object): QueryException: Ordinal parameter not bound ( https://hibernate.atlassian.net/browse/HHH-16828?atlOrigin=eyJpIjoiNDkzYz... )
Issue Type: Bug Affects Versions: 6.0.0, 6.1.5 Assignee: Unassigned Components: hibernate-core, query-criteria Created: 20/Jun/2023 08:25 AM Environment: Alpine 3.17, Eclipse Temurin 17.0.7, Wildfly 27.0.1, Hibernate 6.1.5.Final Priority: Major Reporter: Michael Musenbrock ( https://hibernate.atlassian.net/secure/ViewProfile.jspa?accountId=712020%... )
Hi,
we are currently migrating our code from JavaEE 8 to Jakarta EE 10 and therefore we also migrate from Hibernate 5 to Hibernate 6. Our repository-classes mostly rely on the Criteria API.
We now experience a ‘QueryException: Ordinal parameter not bound’ if the caller passes in null-reference to methods using: cb.equal(root.get(ClassXX.field), null-reference); in the WHERE clause.
In Hibernate 5 this was working and seemed to produced a UNKOWN result and therefore returning an empty result (if only that condition was used).
In Hibernate 6 (6.1.5) a null-value is not added to the parameterBindings in the QuerySqmImpl ( https://github.com/hibernate/hibernate-orm/blob/527bdbdaf578cb3ec0abb9d74... ) and therefore results in a QueryParameterException once the queryParameters are validated ( https://github.com/hibernate/hibernate-orm/blob/527bdbdaf578cb3ec0abb9d74... ).
The JPA 3.1 Specification for Input Parameters ( https://jakarta.ee/specifications/persistence/3.1/jakarta-persistence-spe... ) only states that if the input parameter is null it will yield an unkown value. UNKOWN is fine, but I would not expect an Exception here.
From the code it seems that Hibernate 6.2 will throw a different message for the QueryParameterException.
I will try to set-up a small project to demonstrate the behavior.
regards Michael
( https://hibernate.atlassian.net/browse/HHH-16828#add-comment?atlOrigin=ey... ) Add Comment ( https://hibernate.atlassian.net/browse/HHH-16828#add-comment?atlOrigin=ey... )
Get Jira notifications on your phone! Download the Jira Cloud app for Android ( https://play.google.com/store/apps/details?id=com.atlassian.android.jira.... ) or iOS ( https://itunes.apple.com/app/apple-store/id1006972087?pt=696495&ct=EmailN... ) This message was sent by Atlassian Jira (v1001.0.0-SNAPSHOT#100227- sha1:8ffa416 )
1 year, 3 months