An entity class is the main player in a JPA application. It's a class that represents a table in the database, whose instances, in turn, represent rows inside this table. An entity class is no more than a POJO, annotated with @Entity, with a field elected as a primary key and annotated with @Id, as in the following example:
Movie.java
@Entity
public class Movie {
@Id
@GeneratedValue
private long id;
private String title;
public Movie() {
}
public long getId() {
return id;
}
public void setId(long id) {
this.id = id;
}
public String getTitle() {
return title;
}
public void setTitle(String title) {
this.title = title;
}
}
Note that you do not have to create a corresponding table in the database yourself, as the persistence unit is declared with the javax.persistence.schema-generation.database.actionpropertyset to create, which means that the persistence provider is responsible for creating the table in the database, if it does not exist.