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.
- Now, map the entity class and other databases confiuguration in Persistence.xml file.
- Create a persistence class named as UpdateStudent.java under com.javatpoint.jpa.update package to persist the entity object with data.