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);
q.getResultList();
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.