I have the following entities:
@Entity
@Table(name = "employee")
@Inheritance(strategy = InheritanceType.JOINED)
@DiscriminatorColumn(name="TYPE")
public class Employee {}
@Entity
@Table(name = "regular_employee")
@PrimaryKeyJoinColumn(name = "id")
@DiscriminatorValue("R")
public class RegularEmployee extends Employee{}
The problem that hibernate does not use the discriminator value in the queries.
select
employee0_.id as id1_1_,
employee0_.name as name2_1_,
employee0_.type as type3_1_,
employee0_1_.pay_per_hour as pay_per_1_0_,
case
when employee0_1_.id is not null then 1
when employee0_.id is not null then 0
end as clazz_
from
employee employee0_
left outer join
regular_employee employee0_1_
on employee0_.id=employee0_1_.id
Shouldn't hibernate use the discriminator value in the "left jouter join" section? Something like:
left outer join
regular_employee employee0_1_
on employee0_.type='R' and employee0_.id=employee0_1_.id
I'm guessing this would bring a boost in performance.
Thanks, Tekin.