New Entity Classes from Database Wizard: Database Tables
See Also
This wizard generates a set of entity classes based on tables from an existing database connection or schema.
In this wizard you choose the data source or connection to your database and the tables in that database with the fields that you want to persist.
The IDE then generates an entity class for each of these tables and any related tables with persistent fields.
You open the wizard by right-clicking a
project node or subnode and choosing New Other, selecting the Persistence category and then selecting Entity Classes from Database.
Use this page of the wizard as follows:
- Select one of the following:
- Data Source. Select this option if you want to generate the entity classes directly from a database.
Select the JNDI name of the data source from the drop-down menu.
If the data source you want is not listed, choose New Data Source in the drop-down menu.
- When choosing a data source, the server must be running and the data source must be registered with the server.
- The drop-down menu contains the database connections registered with the IDE if your target server is not a Java EE 5 container
or if the target project is a Java SE project.
- Database Schema. Select this if you already have a database schema you want to use.
The drop-down menu displays the database schemas that are found in the src/conf directory of your project.
- Select any tables in the left panel and click the Add button. If the table
references other tables, the referenced tables are automatically added to the Selected Tables list in the right pane.
The referenced tables are greyed out to indicate that they are referenced tables.
You can place your cursor over the referenced tables to see a tooltip indicating which table references the table.
The IDE automatically generates entity classes for each of the tables listed in the right pane.
- If you do not want entity classes created from referenced tables, deselect Include Related Tables.
- Click Next to confirm the entity class names and specify where to save the entity classes.
- See Also
- About Java Persistence
- Generating Persistent Entity Classes from a Database
- Connecting to a Database
- Obtaining a Database Schema
- About Connection Pools
Legal Notices