|
I have the following model:
@Entity
class Department { ... }
@Entity
@Table(name = "Users")
@Inheritance(strategy = InheritanceType.JOINED)
class User { ... }
@Entity
class Customer extends User {
@ManyToOne(optional=false)
Department belongTo;
}
em.find(Customer.class, id) generates following sql:
select
customer0_.id as id1_2_0_,
customer0_1_.name as name2_2_0_,
customer0_.belongTo_id as belongTo2_0_0_,
department1_.id as id1_1_1_,
department1_.name as name2_1_1_
from
Customer customer0_
inner join
Users customer0_1_
on customer0_.id=customer0_1_.id
inner join
Department department1_
on customer0_.belongTo_id=department1_.id
where
customer0_.id=?
The code above works fine, the customer instance is found.
em.find(User.class, id) generates following sql (should return)
select
user0_.id as id1_2_0_,
user0_.name as name2_2_0_,
user0_1_.belongTo_id as belongTo2_0_0_,
case
when user0_1_.id is not null then 1
when user0_.id is not null then 0
end as clazz_0_,
department1_.id as id1_1_1_,
department1_.name as name2_1_1_
from
Users user0_
left outer join
Customer user0_1_
on user0_.id=user0_1_.id
inner join
Department department1_
on user0_1_.belongTo_id=department1_.id
where
user0_.id=?
The code above does not work (instance of user not found) since Department join is an inner join. This was not the behavior of earlier versions 3.3.x.
See attached code for complete code and tests.
|