[hibernate-issues] [Hibernate-JIRA] Created: (HHH-5637) Allow overridden column names with "table per concrete class" inheritance
Mark A. Ziesemer (JIRA)
noreply at atlassian.com
Fri Oct 8 11:54:57 EDT 2010
Allow overridden column names with "table per concrete class" inheritance
-------------------------------------------------------------------------
Key: HHH-5637
URL: http://opensource.atlassian.com/projects/hibernate/browse/HHH-5637
Project: Hibernate Core
Issue Type: Improvement
Components: core
Affects Versions: 3.5.6
Reporter: Mark A. Ziesemer
Per http://docs.jboss.org/hibernate/stable/core/reference/en/html/inheritance.html#inheritance-tableperconcrete for "Table per concrete class":
{quote}
The limitation of this approach is that if a property is mapped on the superclass, the column name must be the same on all subclass tables.
{quote}
At one point, this documentation also mentioned ([source|http://viewvc.jboss.org/cgi-bin/viewvc.cgi/hibernate/core/trunk/documentation/manual/src/main/docbook/en-US/content/inheritance_mapping.xml?r1=14652&r2=15831]):
{quote}
(We might relax this in a future release of Hibernate.)
{quote}
I've not found a related task for this, so I'm creating this task as a request to support this.
For one use case, I have several related tables that would work very well with polymorphic queries. They have many related columns, but with slightly different column names, e.g. "{{header_id}}" vs. "{{item_header_id}}" (this is arguably poor DB schema design, but is a 3rd party DB that we can't modify). I'm currently able to work with it by using the "implicit polymorphism" alternative. In some cases, I'm using {{@AttributeOverride}}, and in other cases the properties are defined in the parent abstract class as {{@Transient}}, and then overridden in the child concrete classes with the appropriate {{@Column}} annotated per-class.
Unfortunately, without using {{TABLE_PER_CLASS}}, SQL unions are not used. This negatively impacts database performance, and doesn't allow for DB-side ordering and setting a maximum # of results.
When attempting {{TABLE_PER_CLASS}}, Hibernate already generates SQL similar to the following:
{code:SQL}
Select entityId_, field1_, field2_ From (
Select entityId As entityId_, field1 As field1_, field2 As field2_ From table1
Union Select entityId As entityId_, field1 As field1_, field2 As field2_ From table2
);
{code}
Hibernate should allow {{@AttributeOverride}}'s or {{@Column}} annotations on the subclasses to override the column names per table. For example:
{code:SQL}
Select entityId_, field1_, field2_ From (
Select header_id As entityId_, field1 As field1_, field2 As field2_ From table1
Union Select item_header_id As entityId_, field1 As field1_, field2 As field2_ From table2
);
{code}
--
This message is automatically generated by JIRA.
-
If you think it was sent incorrectly contact one of the administrators: http://opensource.atlassian.com/projects/hibernate/secure/Administrators.jspa
-
For more information on JIRA, see: http://www.atlassian.com/software/jira
More information about the hibernate-issues
mailing list