We can easily insert the data into the database through the entity. The EntityManager provides persist() method to add records. The following steps are used to insert the record into the database.
Create an entity class, for example, Student.java with the attribute student_name.
package com.javatpoint.jpa.student;
import javax.persistence.*;
@Entity
@Table(name="student")
publicclass Student {
@Id
private String s_name;
public StudentEntity(String s_name) {
super();
this.s_name = s_name;
}
public StudentEntity() {
super();
}
public String getS_name() {
return s_name;
}
publicvoid setS_name(String s_name) {
this.s_name = s_name;
}
}
Now, map the entity class and other databases configuration in Persistence.xml file.
Disclimer: PCDS.CO.IN not responsible for any content, information, data or any feature of website.
If you are using this website then its your own responsibility to understand the content of the website