Javatpoint Logo
Javatpoint Logo

JPA Joined strategy

In 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 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: -

  • Create a root entity class under the com.javatpoint.jpa.inheritence package and specify all the required variables and annotations.

  • Create an entity class (subclass of under com.javatpoint.jpa.inheritence package.

  • Create another entity class (subclass of under com.javatpoint.jpa.inheritence package.

  • Now, map the entity class and other databases confiuguration in Persistence.xml file.


  • Create a persistence class under com.javatpoint.jpa.persistence package. This class is used to initialize an object and persist it.

After the execution of program, the following directory hierarchy is generated under the MySQL workbench.

JPA Joined strategy


Now, fetch data from each table separately to generate the output.

  • Select * from employee_details

JPA Joined strategy
  • Select * from active_employee

JPA Joined strategy
  • Select * from retired_employee

JPA Joined strategy

Youtube For Videos Join Our Youtube Channel: Join Now


Help Others, Please Share

facebook twitter pinterest

Learn Latest Tutorials


Trending Technologies

B.Tech / MCA