JPA Joined strategyIn joined strategy, a separate table is generated for every entity class. The attribute of each table is joined with the primary key. It removes the possibility of duplicacy. The following syntax represents the joined strategy: - Joined Strategy ExampleIn 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: -
Employee.java
ActiveEmployee.java
RetiredEmployee.java
Persistence.xml
EmployeePersistence.java After the execution of program, the following directory hierarchy is generated under the MySQL workbench. ![]() Output: Now, fetch data from each table separately to generate the output.
![]()
![]()
![]()
Next TopicJPA Table-per-class Strategy
|