JPA Single Table Strategy
The single table strategy is one of the most simplest and efficient way to define the implementation of inheritance. In this approach, instances of the multiple entity classes are stored as attributes in a single table only.
The following syntax represents the single table strategy: -
Single Table Strategy Example
In this example, we will categorize employees into active employees and retired employees.
Thus, the subclass ActiveEmployees and RetiredEmployees inherits the e_id and e_name fields of parent class Employee.
Now, follow the below steps to create JPA project: -
After the execution of the program, run select * from employee_details query in MySQL database to generate the following output: -