# 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.

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

   Generating Entities

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

   To create a new database connection, click Add connection.

   After connecting to the database, click Next.

3. On the Generate Entities from Tables dialog dialog, select the tables from which to generate Java persistent entities and 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: Generating Entities from Tables illustrates how Eclipse generates entities from tables.

Generating Entities from Tables

Creating a new JPA project

Project Properties page – JPA Options