Unnecessary inner joins with super-classes in a JOINED inheritance hierarchy generated for a SUBSELECT fetch query in Hibernate
Issue
- An association is defined between entities X and C where C is a leaf-class in a
JOINEDinheritance hierarchy (C extends B which extends A). -
In the SQL below generated for a
SUBSELECTfetch query, theinner joinclauses (on B and A) are not needed to filter the result set since the association is defined at the leaf (between X and C) and no properties/columns of B nor A are referenced in the query.select x.property1, ... from X x where x.fk in ( select c.id from C c inner join B b on c.id=b.id inner join A a on c.id=a.id where c.something=? )
Environment
- Red Hat JBoss Enterprise Application Platform (EAP) 7
- Hibernate 5
Subscriber exclusive content
A Red Hat subscription provides unlimited access to our knowledgebase, tools, and much more.