Generate Persistence Mapping - Import dialogs
From the Persistence tool window: Right-click a module, persistence unit or session factory, point to Generate Persistence Mapping and select the necessary option.
Specify the settings for generating entity classes and object/relational mappings for them. Depending on the option that you selected, one of the following is used as a source:
- A database schema represented by a data source.
- An EJB facet, if exists in the current project, or, to be more exact, the deployment descriptor file ejb-jar.xml associated with that facet. (Only the <entity> elements are processed.)
- Only for JPA: a Hibernate object/relational mapping file (.hbm.xml). The file should be within the current project.
General Settings
Item | Description |
---|---|
Choose Data Source |
When importing a database schema:
Specify the data source
to be used as a source of import.
|
Choose EJB Facet |
When importing an EJB facet: Specify the EJB facet to be used as a source.
|
Choose Hibernate XML |
When importing a Hibernate object/relational mapping file:
Specify the .hbm.xml file to be used as a source.
|
Package |
The destination package for your entity classes.
|
Entity prefix | One or more characters to be used as a prefix for your entity class names. |
Entity suffix | One or more characters to be used as a suffix for your entity class names. |
Prefer primitive types |
When importing a database schema: Prefer primitive field types to object types
(e.g. when int and java.lang.Integer are the alternatives). |
Show default relationships | When importing a database schema: If this check box is selected, IntelliJ IDEA analyzes the foreign keys in the tables and suggests to create corresponding relationships (e.g. one-to-one, one-to-many). |
Database Schema Mapping
This section is available only when importing a database schema.
Select the tables and columns to be mapped. Edit the names of the entity classes and their persistent fields (the Map As column). Adjust the field types (the Mapped Type column). Use the toolbar for working with relationships and performing other tasks.
Item | Description |
---|---|
![]() | Create a new relationship between the entities. (The Add Relationship dialog will open.) |
![]() | Edit the selected relationship. (The Edit Relationship dialog will open.) |
![]() | Delete the selected relationship. |
![]() | Refresh the database schema. |
![]() | Select all the tables, fields and relationships. |
![]() | Deselect all the tables, fields and relationships. |
![]() | Expand all the nodes in the table. |
![]() | Collapse all the nodes in the table. |