Creating a JPA entity

We will now create the entity class for Course, using Eclipse JPA tools:

  1. Right-click on the CourseManagementEJBs project and select JPA Tool | Generate Entities from Tables:
Figure 7.18: Creating entity from tables
  1. 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
  1. 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 { ...}
..................Content has been hidden....................

You can't read the all page of ebook, please click here login for view all page.
Reset
3.15.220.16