次のエンティティがあります。
@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
「左ジョーター結合」セクションで、休止状態で識別子の値を使用するべきではありませんか? 何かのようなもの:
left outer join
regular_employee employee0_1_
on employee0_.type='R' and employee0_.id=employee0_1_.id
これにより、パフォーマンスが向上すると思います。
ありがとう、テキン。