Hibernate 6 missing discriminator in HQL query compared to 5

It looks like the discriminator is missing in the SQL generated when using hibernate 6. Was this removed on purpose?

String query = "SELECT z.rel.fieldc from B z left join z.rel";
Query q = s.createQuery(query);

Hibernate 5.6.15:
select c1_1_.FIELDC as col_0_0_ from B b0_ left outer join A c1_ on b0_.ID=c1_.ID and c1_.DISCRIMINATOR=‘C’ left outer join C c1_1_ on c1_.ID=c1_1_.ID

Hibernate 6.1.7:
select r1_1.FIELDC from B b1_0 left join (A r1_0 join C r1_1 on r1_0.ID=r1_1.ID) on r1_0.ID=b1_0.ID

This does not seem to affect functionality, but seems to cause negative performance on large tables.

I’m guessing in Hibernate 6 we’re inner joining tables A and C, restricting only entities with this association, and this might be why the discriminator condition is not needed.

Could you please share you entity mappings? Without them is hard to tell what’s going on here.

Currently using the XML files, B has a many to one relationship to C which is a child of A using a discriminator.

<hibernate-mapping package="test">
	<class name="A" table="A" dynamic-insert="true" dynamic-update="true" select-before-update="true" discriminator-value="A">
	<cache usage="read-write"/>
	<id name="id" column="ID">
		<generator class="increment"/>
	<discriminator column="DISCRIMINATOR" type="string" length="30"/>
	<property name="fielda" type="string" column="FIELDA" length="100" />

<hibernate-mapping package="test">
    <class dynamic-insert="true" dynamic-update="true" name="B" select-before-update="true" discriminator-value="B" table="B">
    <id name="id" column="ID" type="long">
        <generator class="increment" />
    <property name="fieldb" type="string" column="FIELDB" length="100"/>
    <many-to-one name="rel" column="ID" class="test.C"
        property-ref="id" update="false" insert="false" not-null="false" not-found="ignore" />

<subclass name="test.C" extends="test.A" dynamic-insert="true" dynamic-update="true" select-before-update="true" discriminator-value="C">
    <join table="C" fetch="select">
    <key on-delete="cascade">
        <column name="ID"/>
    <property name="fieldc" type="string" column="FIELDC" length="100"/>

Please update to Hibernate 6.2.6.Final and if the problem persists, please create an issue in the issue tracker(https://hibernate.atlassian.net) with a test case(https://github.com/hibernate/hibernate-test-case-templates/blob/master/orm/hibernate-orm-6/src/test/java/org/hibernate/bugs/JPAUnitTestCase.java) that reproduces the issue.