I'm getting this runtime error after upgrading java version from 11 to 17
, hibernate version used is 6.3.0.CR1
.
The same code works fine with Java 11
Error at runtime:
Cannot invoke "org.hibernate.query.BindableType.resolveExpressible(org.hibernate.engine.spi.SessionFactoryImplementor)" because "declaredParameterType" is null
We encountered the same error after upgrading from an older Hibernate version to Hibernate 6.2.13.FINAL, alongside a transition from javax.persistence to jakarta.persistence. While I can’t pinpoint the exact version that introduced the regression, the issue arose when preparing a named query:
In the past, invoking setParameter on javax.persistence.Query with a null value for the date was permissible. However, post-upgrade, this is no longer the case, resulting in the exception you’ve encountered.
As a workaround, we now invoke setParameter on jakarta.persistence.Query with the date parameter only when it’s non-null. For null values, we use the overloaded setParameter method that accepts an Object.
To streamline the modification of all relevant calls, we crafted the following utility class:
And we utilize this method as follows:
This approach effectively bypasses the issue, allowing us to handle null values appropriately while preparing our queries.