-
Notifications
You must be signed in to change notification settings - Fork 1
Open
Labels
enhancementNew feature or requestNew feature or requestgood first issueGood for newcomersGood for newcomers
Description
Currently, the foreignKey attribute in a <joinedHierarchy> is mandatory. Consider this example:
<mappingConfig ...>
<entityTable table="LIFEFORM">
<joinedHierarchy>
<rootEntity discriminatorColumn='KIND' discriminator='LF'/>
<entityTable table="MAMMAL" discriminator="MA" foreignKey="FK_MAMMAL_LIFEFORM"/>
<entityTable table="INSECT" discriminator="IN" foreignKey="FK_INSECT_LIFEFORM"/>
</joinedHierarchy>
</entityTable>
</mappingConfig>
However, in most cases we can determine which foreign key to use for an <entityTable> automatically: We only need to look for the foreign referring to the root table. The only time we need a distinction is when a table has more than one foreign key referring to the root table and the default does not suffice.
The proposal:
- if
foreignKeyis specified, it determines the foreign key to use for joins with the root table - If
foreignKeyis absent, derive the foreign key like this:- iterate over all foreign keys
- stop iteration at the first foreign key which refers to the root table and use that
- if no foreign key is found, it is an error.
Metadata
Metadata
Assignees
Labels
enhancementNew feature or requestNew feature or requestgood first issueGood for newcomersGood for newcomers