Javatpoint Logo
Javatpoint Logo

Inserting an Entity

In JPA, we can easily insert data into database through entities. The EntityManager provides persist() method to insert records.

JPA Entity Insertion Example

Here, we will insert the record of students.

This example contains the following steps: -

  • Create an entity class named as under com.javatpoint.jpa.student package that contains attributes s_id, s_name, s_age.

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


  • Create a persistence class named as under com.javatpoint.jpa.persist package to persist the entity object with data.


After the execution of the program, the student table is generated under MySQL workbench.This table contains the student details.To fetch data, run select * from student query in MySQL.

JPA Inserting an Entity

Youtube For Videos Join Our Youtube Channel: Join Now


Help Others, Please Share

facebook twitter pinterest

Learn Latest Tutorials


Trending Technologies

B.Tech / MCA