While working on the upgrade to WildFly 27, we ran into the issue below. The case runs fine on Hibernate ORM 5.6.14 and 5.3.28 (on WildFly 26.1.2).
When using an equals restriction on the root of a (sub)query, you get a {{ClassCastException}} in {{QueryParameterBindingsImpl.generateQueryKeyMemento}} because {{mappingType}} is a {{SingleTableEntityPersister}} (which is not {{JavaTypedExpressible}}). The example in the testcase does not make much sense, because it was reduced to the bare minimum. In our case a restriction was placed on the root of a subquery, which triggers the same exception. Note that the testcase itself triggers an {{AssertionError}} because of the {{assert}} just above the cast. In the testcase query caching has been enabled in the persistence.xml.
{noformat}java.lang.AssertionError at org.hibernate.query.internal.QueryParameterBindingsImpl.generateQueryKeyMemento(QueryParameterBindingsImpl.java:174) at org.hibernate.cache.spi.QueryKey.from(QueryKey.java:47) at org.hibernate.sql.exec.internal.JdbcSelectExecutorStandardImpl.resolveJdbcValuesSource(JdbcSelectExecutorStandardImpl.java:503) at org.hibernate.sql.exec.internal.JdbcSelectExecutorStandardImpl.doExecuteQuery(JdbcSelectExecutorStandardImpl.java:350) at org.hibernate.sql.exec.internal.JdbcSelectExecutorStandardImpl.executeQuery(JdbcSelectExecutorStandardImpl.java:166) at org.hibernate.sql.exec.internal.JdbcSelectExecutorStandardImpl.list(JdbcSelectExecutorStandardImpl.java:91) at org.hibernate.sql.exec.spi.JdbcSelectExecutor.list(JdbcSelectExecutor.java:31) at org.hibernate.query.sqm.internal.ConcreteSqmSelectQueryPlan.lambda$new$0(ConcreteSqmSelectQueryPlan.java:102) at org.hibernate.query.sqm.internal.ConcreteSqmSelectQueryPlan.withCacheableSqmInterpretation(ConcreteSqmSelectQueryPlan.java:305) at org.hibernate.query.sqm.internal.ConcreteSqmSelectQueryPlan.performList(ConcreteSqmSelectQueryPlan.java:246) at org.hibernate.query.sqm.internal.QuerySqmImpl.doList(QuerySqmImpl.java:546) at org.hibernate.query.spi.AbstractSelectionQuery.list(AbstractSelectionQuery.java:363) at org.hibernate.query.sqm.internal.QuerySqmImpl.list(QuerySqmImpl.java:1032) at org.hibernate.query.Query.getResultList(Query.java:94) at org.hibernate.bugs.JPAUnitTestCase.hhh15716Test(JPAUnitTestCase.java:50){noformat} |
|