Skip Headers
Dali Java Persistence Tools User Guide
Release 3.2
Release 3.2
  PDF
PDF
Go To Table Of Contents
Contents
Go To Index
Index

Previous
Mapping an entity
 
Next
Generating tables from entities
 

Generating entities from tables

Use this procedure to generate Java persistent entities from database tables. You must create a JPA project and establish a database connection before generating persistent entities. See "Creating a new JPA project" for more information.

To use the Generate Tables from Entities wizard:

  1. Right-click the JPA project in the Project Explorer and select JPA Tools > Generate Entities from Tables.

    Figure 3-61 Generating Entities from Tables

    Using the JPA Tools > Generate Entities menu option.
  2. On the Select Tables page of the Generate Entities from Tables wizard, select your database connection and schema.

    To create a new database connection, click Add connection.

    If you are not currently connected to the database, the Database Connection page appears. Select your database connection and schema, and click Reconnect.

    Figure 3-62 Select Tables


  3. After selecting a schema, select the tables from which to generate Java persistent entities and click Next.

  4. On the Table Associations page, select the associations to generate. You can specify to generate specific references for each association.

    To create a new association, click Add Association. Use the Create New Association wizard wizard to define the association.

    Figure 3-63 Table Associations


  5. After editing the table associations, click Next.

  6. On the Customize Default Entity Generation page, customize the mapping and class information for each generated entity.

    Figure 3-64 Customize Default Entity Generation


  7. After customizing the mappings, click Next.

  8. On the Customize Individual Entities page, review the mapping and class information for each entity that will be generated, then click Finish.

    Figure 3-65 Customize Individual Entities


Eclipse creates a Java persistent entity for each database table. Each entity contains fields based on the table's columns. Eclipse will also generate entity relationships (such as one-to-one) based on the table constraints. Figure 3-66 illustrates how Eclipse generates entities from tables.

Figure 3-66 Generating Entities from Tables

This figure shows the EMPLOYEE and ADDRESS entities generated from database tables.

Related tasks

Related reference