IntelliJ IDEA 14.0.0 Web 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.

Item Description
Source / Target Use these sections to define the source and target parts of a relationship.
Table
  • 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 name Specify the names of the fields that will be created in the source and target entities respectively.
Type Specify 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 Column Select the desired column name from the drop-down list.
Join Table If 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 Columns Depending 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.png and Remove delete.png buttons to manage the list of join columns.

See Also

Last modified: 4 December 2014
comments powered by Disqus