I'm have a problem with sql created by Hibernate when I use entity mapped shared primary key. I'm using JPA 2.1 and Hibernate 5.2.2
Here's my entities:
@Entity
@Column(name = "employee_table")
public class EmployeeEntity {
@Id
@Column(name = "id")
@SequenceGenerator
@GeneratedValue
private Long id;
@OneToOne(fetch = FetchType.LAZY)
@PrimaryKeyJoinColumn
private EmployeeDetailsEntity employeeDetailsEntity;
}
@Entity
@Table(name = "employee_details")
public class EmployeeDetailsEntity {
@Id
@Column(name = "id")
private Long id;
// additional attributes
}
I want to select all employees which has details:
select e from EmployeeEntity e where e.employeeDetailsEntity is not null;
Select that was generated by Hibernate is:
select employeeen0_.id from employee_table employeeen0_ where employeeen0_.id is not null;
Could you please explaine me what I'm doing wrong and help to solve this?