Problem after upgrading from Hibernate 5.1 to 5.3


Hello everyone,

we have a problem with an application using Hibernate as JPA implementation. On Wildfly 12 with Hibernate 5.1 everything works fine. With Wildfly 15 and the included Hibernate 5.3 version the deployment fails with the following exception:

Caused by: java.lang.ClassCastException: cannot be cast to org.hibernate.loader.plan.spi.EntityQuerySpace
        at org.hibernate.loader.plan.exec.internal.LoadQueryJoinAndFetchProcessor.addJoins(
        at org.hibernate.loader.plan.exec.internal.LoadQueryJoinAndFetchProcessor.renderCollectionJoin(
        at org.hibernate.loader.plan.exec.internal.LoadQueryJoinAndFetchProcessor.renderJoin(
        at org.hibernate.loader.plan.exec.internal.LoadQueryJoinAndFetchProcessor.processQuerySpaceJoin(
        at org.hibernate.loader.plan.exec.internal.LoadQueryJoinAndFetchProcessor.processQuerySpaceJoins(
        at org.hibernate.loader.plan.exec.internal.LoadQueryJoinAndFetchProcessor.processQuerySpaceJoin(
        at org.hibernate.loader.plan.exec.internal.LoadQueryJoinAndFetchProcessor.processQuerySpaceJoins(
        at org.hibernate.loader.plan.exec.internal.LoadQueryJoinAndFetchProcessor.processQuerySpaceJoins(
        at org.hibernate.loader.plan.exec.internal.AbstractLoadQueryDetails.generate(
        at org.hibernate.loader.plan.exec.internal.EntityLoadQueryDetails.<init>(
        at org.hibernate.loader.plan.exec.internal.BatchingLoadQueryDetailsFactory.makeEntityLoadQueryDetails(
        at org.hibernate.loader.entity.plan.AbstractLoadPlanBasedEntityLoader.<init>(
        at org.hibernate.loader.entity.plan.EntityLoader.<init>(
        at org.hibernate.loader.entity.plan.EntityLoader.<init>(
        at org.hibernate.loader.entity.plan.EntityLoader$Builder.byUniqueKey(
        at org.hibernate.loader.entity.plan.EntityLoader$Builder.byPrimaryKey(
        at org.hibernate.loader.entity.plan.AbstractBatchingEntityLoaderBuilder.buildNonBatchingLoader(
        at org.hibernate.loader.entity.BatchingEntityLoaderBuilder.buildLoader(
        at org.hibernate.persister.entity.AbstractEntityPersister.createEntityLoader(
        at org.hibernate.persister.entity.AbstractEntityPersister.createEntityLoader(
        at org.hibernate.persister.entity.AbstractEntityPersister.createLoaders(
        at org.hibernate.persister.entity.AbstractEntityPersister.postInstantiate(
        at org.hibernate.metamodel.internal.MetamodelImpl.initialize(
        at org.hibernate.internal.SessionFactoryImpl.<init>(
        ... 11 more

Can anyone point me in the right direction how to fix this problem?

Best regards



Try to replicate it with this test case template so we can analyse it.


I think the issue was introduced by .

Apparently we can have composite spaces here too, not only entity spaces.

We have 5.3.8.Final planned for next week so it would be really nice to get a test case.

@Jens_Pelzetter could you get us a test case based on our test case template soon? I’m pretty sure it should be easy if you extract the model/query causing the exception.


@Jens_Pelzetter any progress on the test case? Thanks.


Hello all,

sorry for the delay. It was not so easy to extract the entities causing the problem. But now I was able to reproduce the problem. Test case is here:

The problem seams to be that we have an multiple (?) Embeddables of the same type (?) in the subclasses of a common base class. With Hibernate 5.1 everything works fine, starting with Hibernate 5.2 the expectation occurs. Therefore I think that is is a bug in Hibernate. Or do we do something which once worked but should not work?

Thanks and Best regards




any findings so far? This problem is becoming quite problematic for us. Therefore it found be nice to know if it is a bug in Hibernate or if we are doing something which is not supposed to work… In which case we will have to consider how refactor our entities.

Best regards



@Jens_Pelzetter Thanks for the test case. I created the HHH-13269 for it. Indeed it worked until 5.2.13. This is a regression due to HHH-11544.

I created this Pull Request which you can follow if you’re interested in this fix.


@vlad: Many thanks for your response. Good to know that we did not use something which was never supposed to work ;-).

I think we can wait until a Hibernate release with your fix is published. In the meantime we will stick with Wildfly 12 and Hibernate 5.1.x

Best regards