Dali Java Persistence Tools User Guide Release 3.2 Release 3.2 |
|
Mapping an entity |
Generating tables from entities |
Home > User Guide > Tasks > Generating entities from ta...
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:
Right-click the JPA project in the Project Explorer and select JPA Tools > Generate Entities from Tables.
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.
After selecting a schema, select the tables from which to generate Java persistent entities and click Next.
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.
After editing the table associations, click Next.
On the Customize Default Entity Generation page, customize the mapping and class information for each generated entity.
After customizing the mappings, click Next.
On the Customize Individual Entities page, review the mapping and class information for each entity that will be generated, then click Finish.
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.
Related tasks
Related reference