TABLE_PER_CLASS Inheritance how can I get all records from two tables

36 Views Asked by At

I have two entities:

@Entity
@Inheritance(strategy = InheritanceType.TABLE_PER_CLASS)
public class Employee {

    @Id
    @GeneratedValue(strategy = GenerationType.AUTO)
    private Long id;

    private String name;
}

and

@Entity
public class ActiveEmployee extends Employee {

    private Double salary;

    private Date date;
}

Now I want to get all records from two tables and I don't how to do it?

If I use EmployeeRepository and method findAll() I have also records from ActiveEmployee but without its own fields salary and date. I want to get records with this fields and when it is Employee this fields should be null. How to join this tables?

0

There are 0 best solutions below