Javatpoint Logo
Javatpoint Logo

Update an Entity

JPA allows us to change the records in database by updating an entity.

JPA Entity Update Example

Here, we will update the age of a student on the basis of primary key.

This example contains the following steps: -

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

StudentEntity.java

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

Persistence.xml

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

UpdateStudent.java

Output:


JPA Update an Entity




Youtube For Videos Join Our Youtube Channel: Join Now

Help Others, Please Share

facebook twitter pinterest

Learn Latest Tutorials


Preparation


Trending Technologies


B.Tech / MCA