Lesson 1.4: Create entity beans from the database tables
In this lesson you will learn how generate JPA entity beans from tables in the sample Derby database that you connected to in the previous lesson.
Before you begin, complete Lesson 1.3: Create a connection to a database.
Generate JPA entity beans
- Right-click the project and then click
JPA Tools | Generate Entities.
- In the Database Connection window, ensure that the database connection that you created in the previous lesson is selected.
- For Schema, select
SAMP from the drop-down list. If the drop-down list does not work, click
Reconnect and then try selecting the SAMP schema again. Click Next.
- On the Generate Entities from Tables page, type employee.list in the Package field.
- On the same page, select
Synchronize classes in persistence.xml.
- In the Tables list, select
Department and
Employee and then click Finish.
The package employee.list is created and populated with two entities, Employee.java and Department.java.
Lesson checkpoint
You have completed Lesson 1.3. In this lesson, you learned how to generate JPA entity beans from tables in the sample Derby database.