IntelliJ IDEA 2016.1 Help

Add Relationship

Persistence Tool Window | context menu of a module or persistence unit | Generate Persistence Mapping | By Database Schema | Add relationship

Use this dialog box to set up a relation between two entities of a persistence unit according to the relation between the corresponding tables of the selected database.

Source / TargetUse these sections to define the source and target parts of a relationship.
  • In the Source section, this field is read-only and displays the name of the table selected in the Import Database Schema dialog box.
  • In the Target section, select the desired table from the list of tables available in the current data source.
Attribute nameSpecify the names of the fields that will be created in the source and target entities respectively.
TypeSpecify the relationship type by selecting appropriate options from the drop-down lists in the Source and Target sections. The list contains Java types, thus enabling you to define the Java code that will be generated for the relationship.
Map Key ColumnSelect the desired column name from the drop-down list.
Join TableIf this check box is selected, the data will be queried from both tables on the basis of the specified relationship. Select the desired join table from the list of tables available in the data source.
For the many-to-many relationships, this check box is selected by default, and not editable.
Join ColumnsDepending on the type of relationship, this table features the following columns:
  • For one-to-one or one-to-many relationships, the table contains two columns:
    1. Source Column - in this field, specify the foreign key of the source table.
    2. Target Column - in this field, specify the referenced field in the target table.
  • For multiple relationships, four columns are available:
    1. Source Column
    2. Source Join Column
    3. Target Join Column
    4. Target Column

Use the Add add and Remove delete buttons to manage the list of join columns.

See Also

Last modified: 13 July 2016