IntelliJ IDEA 14.0.0 Web Help

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.

General settings

Item Description Available In
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 browseButton 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 browseButton 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 browseButton 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

Item Description Available In
add.png 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
vcsToolbarJumpToSourceIcon.gif Click this button to change properties of the selected relationship in the Edit Relationship dialog box. Import Database Schema
delete.png Click this button to delete the selected relationship.
refresh.png Click this button to refresh the database schema. Import Database Schema
iconSelectAllRemoteRunDialog.gif Click this button to select all tables, fields, and relations and have IntelliJ IDEA involve them in the mapping generation. Import Database Schema
iconUnSelectAllRemoteRunDialog.gif Click this button to clear selection of all tables, fields, and relations and thus exclude them from the mapping generation. Import Database Schema
expandAll.gif Click this button to expand all table nodes. Import Database Schema
collapseAll.png 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 add.png, 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 icon_newXmlFile.png 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.
All
Generate Column Properties Select this check box to have properties of fields of the table reflected in the XML file or through annotations. All

The following options define the format used to maintain the mappings between the database tables and persistence entities. This may be an XML file or several XML files and/or JPA annotations.

For the necessary mappings to be generated, at least one of the options should be selected.

The options Generate Single Mapping XML and Generate Separate XML for Entity are mutually exclusive and cannot be selected at the same time.

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:

  1. Click add.png.
  2. If you are working in the context of a Hibernate facet, select the target file format (Hibernate mapping or JPA mapping descriptor (JPA ORM)).
  3. Select the desired file from the file chooser dialog box.

    If the desired file doesn't exist, select the directory where the new file should be created, click icon_newXmlFile.png, and type the file name in the New File dialog box.

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

All
Generate JPA annotation Check this option to create mapping information as annotations in the source code of the entity classes. All

See Also

Last modified: 4 December 2014
comments powered by Disqus