Recursive one-to-many bi-directional association on subclass with discriminator generates
incorrect DDL/SQL
-----------------------------------------------------------------------------------------------------------
Key: HHH-7105
URL:
https://hibernate.onjira.com/browse/HHH-7105
Project: Hibernate ORM
Issue Type: Bug
Components: core
Affects Versions: 4.1.0, 3.6.10
Environment: Tested on PostgreSQL 8.3
Reporter: yojustinwalsh(a)gmail.com
Attachments: subclass-joined-to-parent-with-set.zip
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
--
This message is automatically generated by JIRA.
For more information on JIRA, see:
http://www.atlassian.com/software/jira