Javatpoint Logo
Javatpoint Logo

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

  • Create a root entity class under the com.javatpoint.jpa.inheritence package and specify all the required attributes 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, run select * from employee_details query in MySQL database to generate the following output: -

JPA Single Table 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