We will now create the entity class for Course, using Eclipse JPA tools:
- Right-click on the CourseManagementEJBs project and select JPA Tool | Generate Entities from Tables:
Figure 7.18: Creating entity from tables
- Select the Course table and click Next. Click Next in the Table Associations window. On the next page, select identity as Key generator:
Figure 7.19: Customizing JPA entity details
- Enter the package name. We do not want to change anything on the next page, so click Finish. Notice that the wizard creates a findAll query for the class that we can use to get all courses:
@Entity @NamedQuery(name="Course.findAll", query="SELECT c FROM
Course c") public class Course implements Serializable { ...}