[hibernate-issues] [Hibernate-JIRA] Resolved: (HHH-3748) foreign key attributed to wrong table when table for subclass with inheritance model is used

Gail Badner (JIRA) noreply at atlassian.com
Thu Apr 29 18:06:29 EDT 2010


     [ http://opensource.atlassian.com/projects/hibernate/browse/HHH-3748?page=com.atlassian.jira.plugin.system.issuetabpanels:all-tabpanel ]

Gail Badner resolved HHH-3748.
------------------------------

      Assignee: Gail Badner
    Resolution: Duplicate

> foreign key attributed to wrong table when table for subclass with inheritance model is used
> --------------------------------------------------------------------------------------------
>
>                 Key: HHH-3748
>                 URL: http://opensource.atlassian.com/projects/hibernate/browse/HHH-3748
>             Project: Hibernate Core
>          Issue Type: Bug
>          Components: core
>    Affects Versions: 3.3.1, 3.5.0.Beta-1
>         Environment: Tested with 3.3.1.GA + Oracle and 3.4 (trunk) + hsqldb.
>            Reporter: Paul Pogonyshev
>            Assignee: Gail Badner
>         Attachments: test.diff
>
>
> When a collection of inherited objects (using table per subclass with discriminator model) is mapped, foreign key is always attributed to the base class table, not inherited class table.  This means fields in inherited class tables are _unusable_ as keys for collections, or at least I don't see any way to use them.
> This is a workaroundable issue for new databases (you could move the field to the base table, even if this is suboptimal), but a blocker for interfacing already existing database schemas.
> I tried to create a testcase for this, attached is a diff against trunk.  The test doesn't visibly fail, because I do not know how to check which table it references.  However, you can see in ASTParserLoadingTest-output.txt:
>     create table DIBase (
>         id bigint generated by default as identity (start with 1),
>         type varchar(255) not null,
>         container bigint,
>         primary key (id)
>     )
>     create table DISubclass1 (
>         id bigint not null,
>         container bigint,
>         primary key (id)
>     )
> I.e. field 'container' ends up in both base and derived class tables.  Second is because of the 'many-to-one'.  First is because foreign key from 'children' bag is attributed to a wrong table: instead, Hibernate should reuse the column in DISubclass1 table.
> Might be related to issue 3500.

-- 
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