We have already created JavaBeans for Course, Person, Student, and Teacher. We will now convert them to JPA entities using the @Entity annotation. Open Course.java and add the following annotations:
@ManagedBean (name="course") @RequestScoped @Entity public class Course implements Serializable
The same bean can act as a managed bean for JSF and an entity for JPA. Note that if the name of the class is different from the table name in the database, you will need to specify a name attribute of the @Entity annotation. For example, if our Course table were called SchoolCourse, then the entity declaration would be as follows:
@Entity(name="SchoolCourse")
To specify the primary key of the Entity, use the @Id annotation. In the ...