Import Database Schema / Import Mappings
Persistence Tool Window | context menu of a module, session factory, or persistence unit | Generate Persistence Mapping
The dialog boxes Import Database Schema, Import Hibernate Mappings and Import Entity EJBs are used to create annotated Java classes and persistence metadata. The dialog boxes are similar, and the differences are specially marked.
|Choose Data Source||Use this field to select the data source to be mapped. You can select the desired data source from the drop-down list of recent choices or click the Browse button and select one from the Data Sources dialog box. Refer to Mapping to Data Source.||Import Database Schema|
|Choose Hibernate XML||Use this field to select the Hibernate configuration file to be mapped. You can select the desired Hibernate configuration file from the drop-down list of recent choices, or click the Browse button and select one in the dialog that opens. Refer to Mapping to Hibernate.||Import Hibernate Mappings|
|Choose EJB Facet||Use this field to select EJB facet to be mapped. You can select the desired EJB facet from the drop-down list of recent choices, or click the Browse button and select one from the Select Facet dialog box. Refer to Mapping to EJB.||Import Entity EJBs|
|Package||Specify the target package where the mapping files will be generated.||All|
|Entity prefix/suffix||Type the strings that will automatically prepend or appended to the persistence entity name according to the naming conventions accepted in your project. The entered strings are immediately previewed in the Map As and Mapped Type columns of the Database Schema Mapping section.||All|
|Prefer primitive types||If this check box is selected, the import is performed into primitive types, rather than Object types.||Import Database Schema|
|Show default relationships||If this check box is selected, IntelliJ IDEA analyzes foreign keys in the tables and suggests to create corresponding relationships.||Import Database Schema|
Database schema mapping
|Click this button to open the Add Relationship dialog box and create a new relationship between persistence entities according to relations in the database schema.||Import Database Schema|
|Click this button to change properties of the selected relationship in the Edit Relationship dialog box.||Import Database Schema|
|Click this button to delete the selected relationship.|
|Click this button to refresh the database schema.||Import Database Schema|
|Click this button to select all tables, fields, and relations and have IntelliJ IDEA involve them in the mapping generation.||Import Database Schema|
|Click this button to clear selection of all tables, fields, and relations and thus exclude them from the mapping generation.||Import Database Schema|
|Click this button to expand all table nodes.||Import Database Schema|
|Click this button to collapse all table nodes.||Import Database Schema|
|Add to Persistence Unit / Add to Session Factory||If the Generate Persistence Mapping command has been invoked on a
module with the JPA or Hibernate facet, use this field to specify the target persistence entity or session factory.
To define the target persistence unit or session factory, click ,
and select the desired file from the file chooser dialog box. If the desired file doesn't exist,
in the file chooser dialog box, select the directory where the new file should be created, click the
button, and type the file name in the
New File dialog box.
Otherwise, if the dialog box has been invoked from a persistence unit or session factory, the field becomes read-only, and shows the persistence unit or session factory selected in the Persistence tool window.
|Generate Column Properties||Select this check box to have properties of fields of the table reflected in the XML file or through annotations.||All|
For the necessary mappings to be generated, at least one of the options should be selected.
|Generate Single Mapping XML||
Select this check box to have IntelliJ IDEA store object-relational mappings generated for all the entities in the persistence unit or session factory in one XML file.
To define the target file:
|Generate Separate XML for Entity||
Select this check box to have IntelliJ IDEA store object-relational mappings generated for each entity in a separate XML file.
The generated files will have the names of the corresponding entities followed by
|Generate JPA annotation||Check this option to create mapping information as annotations in the source code of the entity classes.||All|