New Entity Classes from Database Wizard: Entity Classes
See Also
This wizard generates a set of entity classes from an existing database connection or schema.
The IDE generates an entity class for each related table with persistent fields.
The wizard takes you through the steps of choosing the database connection or schema,
and then selecting the tables in the database that will be used to generate the entity classes.
You can also use the optional mapping page to configure annotation elements that are generated in the entity class.
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.
In this page of the wizard you set the following:
- Class Names. Displays the name of the class that is generated for each table listed.
The Generation Type column displays if the class will be new, updated or recreated.
- Project. Displays the project where the entity classes will be saved. This field is read only.
- Location. Select the source folder where you want to create the entity class.
- Package. Select an existing package from the Package drop-down list or type the name of a new package.
- Generate Named Query Annotations for Persistent Fields. If selected, the IDE generates named query annotations in the entity classes.
- Generate JAXB Annotations. When selected, the IDE will generate annotations in the entity class
for mapping the class to an XML element that can then be used by a JAXB web service.
- If the entity class for a selected table already exists, you can choose to either recreate the
entity class or update the existing class by using the toggle button (...) below the Class Names table.
From this page you can click Finish to create entity classes for each of the specified tables or
click Next to modify the default settings used when generating the mapping annotations.
- When you select a data source or JDBC connection, the IDE also creates a database schema for the database and saves it in your src/conf folder.
- To persist entity classes, your project requires a persistence unit.
When you create the entity class, the IDE checks if there is a persistence unit for the project.
If the IDE cannot locate a persistence unit, the Create Persistence Unit button appears.
You can click Create Persistence Unit to open the Create Persistence Unit wizard.
Alternatively, you can create a persistence unit later by choosing Persistence > Persistence Unit in the New File wizard.
- See Also
- About Java Persistence
- Generating Persistent Entity Classes from a Database
- Creating a Persistence Unit
Legal Notices