# New Entity Classes from Database Wizard: Entity Classes

Use to generate 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.

In this page of the wizard you set the following:

Element | Description
--- | ---
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 | Specifies the source folder. Select the source folder where you want to create the entity class.
Package | Specifies an existing package. Select a package from the Package drop-down list or type the name of a new package.
Generate Named Query Annotations for Persistent Fields | When selected, the IDE generates named query annotations in the entity classes.
Generate JAXB Annotations | When selected, the IDE generates annotations in the entity class for mapping the class to an XML element that can then be used by a JAXB web service.
Generate MappedSuperclasses instead of Entities | When selected, the IDE generates a mapped superclass instead of an entity class for each table that you selected. Each class is decorated with the `@MappedSuperclass` annotation. When this option is selected the Generate Named Query option is disabled.
Create Persistence Unit | When selected, the IDE generates a persistence unit based upon the selected datasource. This option is not visible if a persistence unit already exists.

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

Related Topics

Developing Applications with NetBeans IDE,

Copyright © 2015, Oracle and/or its affiliates. All rights reserved.