Fixed
Details
Details
Assignee
Ladislav Kulhánek
Ladislav KulhánekReporter
Ladislav Kulhánek
Ladislav KulhánekComponents
Fix versions
Priority
Created September 27, 2018 at 7:54 AM
Updated July 24, 2020 at 7:00 AM
Resolved October 17, 2019 at 9:40 AM
When you have an inheritance hierarchy with "joined" inheritance type and query something from a subclass, superclass is always joined in the query even though it is not needed. Example:
@Entity @Inheritance(strategy = InheritanceType.JOINED) public abstract class A { @Id @GeneratedValue private Long id; private String valA; // getters setters here }
@Entity public class SubA extends A { private String valSubA; // getters setters here }
JPQL query:
select suba.valSubA from SubA suba
Translated SQL query:
select suba0_.valSubA as col_0_0_ from SubA suba0_ inner join A suba0_1_ on suba0_.id=suba0_1_.id
Super class table join is useless in the SQL query. It could be optimized.
I discussed that on Hibernate forum