Recursive one-to-many bi-directional association on subclass with discriminator generates incorrect DDL/SQL

Description

When an inverse one-to-many bi-directional relationship which references a subclass from a parent (abstract) class is mapped with a table-per-subclass strategy, the associated collection is always found to be empty.

The above mapping produces the following two anomalies which goes some way to explain why the associated collection is always empty:
1) An additional foreign key column is generated in the parent table (in the example, TBL_ABSTRACT_CONTAINER) and is never populated
2) The SQL that is generated selects the children based on the presence of this additional foreign key column (which is never populated). The SQL should be using the foreign key column in the child class (TBL_ITEM in the example)

The issue is discussed in detail on the hibernate forum: https://forum.hibernate.org/viewtopic.php?f=1&t=1014446

The attachment is a zipped eclipse/maven project which demonstrates the issue.
Simply unpack the archive, configure the database settings in hibernate-subclassjoinedtoparent.cfg.xml and
mvn test

Environment

Tested on PostgreSQL 8.3

Assignee

Unassigned

Reporter

yojustinwalsh@gmail.com

Fix versions

None

Labels

backPortable

None

Suitable for new contributors

None

Requires Release Note

None

Pull Request

None

backportDecision

None

Components

Affects versions

Priority

Major
Configure