Javatpoint Logo
Javatpoint Logo

JPA Table-per-class Strategy

In table-per-class strategy, for each sub entity class a separate table is generated. Unlike joined strategy, no separate table is generated for parent entity class in table-per-class strategy.

The following syntax represents the table-per-class strategy: -

Table-per-class 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 the program, two tables are generated in MySQL workbench.

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

  • Select * from active_employee

JPA Table-per-class Strategy
  • Select * from retired_employee

JPA Table-per-class Strategy
Next Topic#

Youtube For Videos Join Our Youtube Channel: Join Now


Help Others, Please Share

facebook twitter pinterest

Learn Latest Tutorials


Trending Technologies

B.Tech / MCA