我有以下实体:
@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{}
hibernate 在查询中不使用鉴别器值的问题。
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
hibernate 不应该在“left jouter join”部分使用鉴别器值吗?就像是:
left outer join
regular_employee employee0_1_
on employee0_.type='R' and employee0_.id=employee0_1_.id
我猜这会带来性能的提升。
谢谢,泰金。