Creating JPA entity beans in a JPA project from database tables

You can generate JPA entity beans from existing database tables (bottom-up mapping).

Before you begin

Create a JPA project or enable JPA support in an appropriate project.

About this task

To generate entity beans from tables in a database:

Procedure

  1. In the Package Explorer view, right-click the JPA project and select JPA Tools > Generate Entities from Tables.
  2. On the Generate Custom Entities page, select a database connection and schema. If you have not created the database connection, click the Add connections icon and follow the prompts in New Connection Profile wizard to complete the new connection.
  3. Select the tables from which you want to generate JPA entities.
  4. Create, edit, or delete table associations by using the proper icons. Click Next.
  5. Optionally, you can customize aspects of the entities to be generated, change the package and class, and add interfaces. Click Next.
  6. In the Customize Individual Entities page, you can select tables and columns and set up the mapping values for each one. Click Finish. The entities are generated.
  7. Add a primary key (@Id annotation) to the entities:
    1. In the Package Explorer view, right-click one of the entities and select JPA Tools > Configure JPA Entities
    2. In the Configure JPA Entities wizard, select the entities that you created and then click Next.
    3. Click Primary Key.
    4. Click the entity to configure and then select the attribute to set as the primary key (@Id) for the entity.
    5. Repeat the previous step for any additional entities that need a primary key set.
  8. Optional: Add additional configuration details to the entities before exiting this wizard.
  9. Click Finish.
Icon that indicates the type of topic Task topic
Timestamp icon Last updated: July 17, 2017 21:58

File name: t_jpa_bottomup.html